Chemex Coffee Python App via @zedshaw #LPTHW

Just wrote a quick script that makes use of a function per the extra credit in Exercise 19 of Learn Python the Hard Way.

It calculates the grams of water needed total and grams of water for bloom given an amount of coffee in grams.

Here’s the code:

def coffee_to_water_ratio(coffee_in_g):
    # 48g coffee to 710g water per Intelligentsia's iPhone App
    # 710 / 48 = 14.79g water for every 1g coffee
    # Round 14.79 to 15
    water_in_g = coffee_in_g * 15
    # 48g coffee should bloom with 100g water per Intelligentsia's iPhone App
    # so roughly double the coffee grams to get the optimum bloom water weight in grams
    bloom_in_g = coffee_in_g * 2
    print """
    You've got %s grams of coffee so you'll need %s grams of water total.
    %s grams of that water should be used for the coffee's bloom.
    Your chemex is gonna make some bitchin' brew, brah!!
    """ % (coffee_in_g, water_in_g, bloom_in_g)

print "How many grams of coffee do you have?"
grams_coffee = int(raw_input("> "))

coffee_to_water_ratio(grams_coffee)

Here’s some example output:

[lpthw]$ python ex19a.py
How many grams of coffee do you have?
> 28

    You've got 28 grams of coffee so you'll need 420 grams of water total.
    56 grams of that water should be used for the coffee's bloom.
    Your chemex is gonna make some bitchin' brew, brah!!

Just toss it in a py script and run it with: python script.py