Created
September 5, 2013 12:28
-
-
Save cdodd/6449450 to your computer and use it in GitHub Desktop.
Alcohol by volume (ABV) calculator based on original and final beer gravity readings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
# Get the original and final gravity from the commandline args | |
try: | |
og = float(sys.argv[1]) | |
fg = float(sys.argv[2]) | |
except IndexError: | |
print 'Usage %s <original gravity> <final gravity>' % sys.argv[0] | |
sys.exit(1) | |
# Calculate and print the ABV | |
abv = ((((1.05) * (og - fg)) / fg) / 0.79) * 100 | |
print '%.1f%%' % abv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment