Last active
September 6, 2016 14:24
-
-
Save indeedwatson/4677e60b14e3f0612337066bcf659367 to your computer and use it in GitHub Desktop.
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
# Pizza calculator with baker's percentage | |
# Features: Default master dough recipe, other recipes, mostly from | |
# The Pizza Bible, custom %, saving custom % | |
recipes = {'masterdough': {'water': 64, 'salt': 2, 'yeast': 1, 'oil': 1, | |
'malt': 2}, | |
'chicago': {'water': 60, 'salt': 2, 'yeast': 0.1, 'lard': 1, | |
'butter': 1}, | |
'sicilian': {'water': 70, 'salt': 2, 'yeast': 1, 'malt': 2, | |
'oil': 1}, | |
'refrigerated': {'water': 70, 'salt': 2.6, 'yeast': 0.3}} | |
leftWidth = 12 | |
rightWidth = 7 | |
def bakerCalc(flour, dough, style): | |
print(style.upper().center(leftWidth + rightWidth, '-')) | |
for i in dough[style].keys(): | |
ingredient = int(flour) * int(dough[style][i]) / 100 | |
print(i.title().ljust(leftWidth, '.') + str(ingredient).rjust(rightWidth)) | |
print('Enter a desired flour amount or type "recipes" or "custom" for other' | |
' options:') | |
choice = input('>').lower() | |
if choice == 'recipes': | |
while True: | |
for r in recipes.keys(): | |
print(r) | |
chooseDough = input('Choose one of the above recipes: ').lower() | |
if chooseDough not in recipes.keys(): | |
print(chooseDough + ' is not in the list of recipes!') | |
else: | |
break | |
customFlour = input('Enter the desired amount of flour: ') | |
bakerCalc(customFlour, recipes, chooseDough) | |
elif choice == 'custom': | |
# ask for every ingredient, add it to a dict | |
customFlour = input('Flour: ') | |
print('Enter your custom percentages:') | |
newRecipe = {} | |
for i in recipes['refrigerated'].keys(): | |
percentage = input(i + ': ') | |
newRecipe[i] = percentage | |
for i in newRecipe.keys(): | |
ingredient = int(customFlour) * int(newRecipe[i]) / 100 | |
print(i + ': ' + str(ingredient)) | |
elif choice.isdigit(): | |
bakerCalc(choice, recipes, 'masterdough') | |
else: | |
print(choice + ' is not a valid choice, enter a desired flour amount or' | |
'type "recipe" or "custom" for other options') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment