-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeHS regular code
73 lines (53 loc) · 2 KB
/
CodeHS regular code
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
whole_recipe = []
ingredient_name = ""
ingredient_ounces = ""
ingredient_type = ""
def space(num = 1):
for i in range(num):
print ("")
def operation(multiply_or_divide, number):
if multiply_or_divide == "multiply":
return (float(ingredient_number * number))
if multiply_or_divide == "divide":
return (float(ingredient_number / number))
print ("Welcome to Ms Vashaw's very own recipe multiplier!")
space()
total_ingredients = int(input("How many ingredients? "))
multiply_or_divide = input("Would you like to multiply or divide your recipe? ")
number = float(input("By what? "))
if multiply_or_divide == "divide" and number == 0:
print ("You cannot divide by zero. Please try again. ")
number = float(input("Divide your recipe by what? "))
space()
for i in range(total_ingredients):
count = i + 1
if count == 1:
order = "st"
if count == 2:
order = "nd"
if count == 3:
order = "rd"
if count >= 4:
order = "th"
if count > 11 and count % 10 == 1:
order = "st"
if count > 12 and count % 10 == 2:
order = "nd"
if count > 13 and count % 10 == 3:
order = "rd"
if count % 100 == 0:
order = ""
ingredient_name = input("What will your " + str(count) + order + " ingredient be? ")
ingredient_type = input("Units of measurement used for " + ingredient_name + ": ")
ingredient_number = float(input("How many " + ingredient_type + "? "))
if ingredient_type == "tsp" or "teaspoon":
if ingredient_number * number % 3 == 0:
ingredient_type = "tablespoons"
space()
print ("What you entered: " + str(ingredient_number) + " " + ingredient_type + " of " + ingredient_name)
rounded_number = round(operation(multiply_or_divide, number), 3)
math = str(rounded_number) + ingredient_type + " of " + ingredient_name
whole_recipe.append(math)
space()
space()
print ("Converted recipe: " + str(whole_recipe))