Week 11
Source Code
import random
def main():
# items list
items = ["sword", "scissor"]
done = False
while not done:
print("Menu System")
print("E1 - Example 1")
print("P1 - Problem 1")
print("Q - Quit")
choice = input("Choice: ")
if choice == "E1":
# example1 function call
example1()
elif choice == "E2":
print("Example 2")
# example2 function call
example2()
elif choice == "E3":
print("Example 3")
# example3 function call
example3(items)
elif choice == "E4":
print("Example 4")
# print items
print(items)
elif choice == "P1":
print("Problem 1")
# problem1 function call
elif choice == "P2":
print("Problem 2")
# problem2 function call
elif choice == "Q":
print("Quitting!")
done = True
else:
print("Invalid choice")
# example1 function definition
def example1():
print("Example 1")
# create an empty list
# append values to the list
# print the elements (simple way)
# C-style for loop
# for in loop
# print the min, max and sum
# example2 function definition
def example2():
print("Example 2")
# create a list of states
# where have you visited?
# example3 function definition
def example3(items):
print("Example 3")
# problem1 function definition
# problem2 function definition
# call the main function, do not delete!
main()Final Project
Last updated