25 lines
654 B
Python
25 lines
654 B
Python
|
class recipe:
|
||
|
def __init__(self, ingredients, standardPortions):
|
||
|
self.ingredients = ingredients
|
||
|
self.standardPortions = standardPortions
|
||
|
|
||
|
def getIngredients(self, portions):
|
||
|
ratio = portions / self.standardPortions
|
||
|
for ingredient in self.ingredients:
|
||
|
print(f'{ingredient}: {self.ingredients[ingredient]*ratio}')
|
||
|
|
||
|
cookies = recipe(
|
||
|
ingredients={
|
||
|
'sukker(g)': 400,
|
||
|
'smør(g)': 320,
|
||
|
'sjokolade(g)': 500,
|
||
|
'egg': 2,
|
||
|
'hvetemel(g)': 460
|
||
|
},
|
||
|
standardPortions=48,
|
||
|
)
|
||
|
|
||
|
cookieNumber = int(input('Hvor mange cookies ønsker du å bake? '))
|
||
|
|
||
|
print('Antall cookies:', cookieNumber)
|
||
|
cookies.getIngredients(cookieNumber)
|