This repository was archived by the owner on May 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathRecipe.py
50 lines (41 loc) · 1.41 KB
/
Recipe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
This program asks the user for three ingredients,
three amounts, and a number of servings, and
determines how much of each ingredient is needed
to serve the specified number of servings.
The names of three ingredients for a salad recipe.
The number of ounces of each ingredient required for
one serving (these should just be floats, like 2.5).
The number of servings desired (this should be an
integer). You should only ask for the number of
servings once.
"""
ingredient_one = ""
ingredient_two = ""
ingredient_three = ""
ingredient_one_amount = 0
ingredient_two_amount = 0
ingredient_three_amount = 0
for i in range(3):
x = input("What is the name of ingredient number " + str(i + 1) + "? ")
y = float(input("What is the amount of ingredient " + str(i + 1) + " (oz)? "))
if i == 0:
ingredient_one = x
ingredient_one_amount = y
print("0")
elif i == 1:
ingredient_two = x
ingredient_two_amount = y
print("1")
else:
ingredient_three = x
ingredient_three_amount = y
print("2")
s = int(input("How many servings? "))
tot1 = ingredient_one_amount * s
tot2 = ingredient_two_amount * s
tot3 = ingredient_three_amount * s
print("You will need:")
print(str(tot1) + " times the amount of " + ingredient_one)
print(str(tot2) + " times the amount of " + ingredient_two)
print(str(tot3) + " times the amount of " + ingredient_three)