Skip to content

Instantly share code, notes, and snippets.

@cdodd
Created September 5, 2013 12:28
Show Gist options
  • Select an option

  • Save cdodd/6449450 to your computer and use it in GitHub Desktop.

Select an option

Save cdodd/6449450 to your computer and use it in GitHub Desktop.

Revisions

  1. cdodd created this gist Sep 5, 2013.
    14 changes: 14 additions & 0 deletions abv-calculator.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/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