Activity 3.15
Source Code
import math
import random
import recipe
def main():
print("Main Menu")
print("E1 - Example 1")
print("Q - Quit")
done = False
while not done:
choice = input("Choice: ").upper()
if choice == "Q":
print("Quit!")
done = True
elif choice == "E1":
example1()
elif choice == "E2":
example2()
elif choice == "P1":
pass
elif choice == "P2":
pass
elif choice == "P3":
pass
elif choice == "P4":
pass
elif choice == "P5":
pass
elif choice == "P6":
pass
elif choice == "P7":
pass
elif choice == "P8":
pass
elif choice == "P9":
pass
elif choice == "P10":
pass
elif choice == "Q":
print("Quitting!")
done = True
else:
print("Invalid Choice")
# define Example 1 Function
def example1():
print("Example 1")
# create object
# define Example 1 Function
def example2():
print("Example 2")
# create object
# problem1 function definition
# problem2 function definition
# problem3 function definition
# problem4 function definition
# problem5 function definition
# problem6 function definition
# problem7 function definition
# problem8 function definition
# problem9 function definition
# problem10 function definition
# call to main function, do not delete!
main()
recipe.py
# header
class Recipe:
# constructor
# add_ingredient method
# __str__ method
def __str__(self):
output = self.name + " Recipe\n"
output += "Ingredients:\n"
for i in self.ingredients:
output += i + "\n"
return output
Last updated