Activity 2.20
Source Code
import random
import math
def main():
done = False
while not done:
print("Menu System")
print("E1 - Example 1")
print("E2 - Example 2")
print("P1 - Problem 1")
print("Q - Quit")
choice = input("Choice: ").upper()
if choice == "E1":
# example1 function call
example1()
elif choice == "E2":
# example2 function call
example2()
elif choice == "E3":
print("Example 3")
# example3 function call
elif choice == "P1":
print("Problem 1")
# problem1 function call
elif choice == "P2":
print("Problem 2")
# problem2 function call
elif choice == "P3":
print("Problem 3")
# problem3 function call
elif choice == "P4":
print("Problem 4")
# problem4 function call
elif choice == "P5":
print("Problem 5")
# problem5 function call
elif choice == "P6":
print("Problem 6")
# problem6 function call
elif choice == "P7":
print("Problem 7")
# problem7 function call
elif choice == "P8":
print("Problem 8")
# problem8 function call
elif choice == "P9":
print("Problem 9")
# problem9 function call
elif choice == "P10":
print("Problem 10")
# problem10 function call
elif choice == "Q":
print("Quitting!")
done = True
else:
print("Invalid choice")
# example1 function definition
def example1():
print("Example 1")
# numbers list
# print the first number
# print the last number
# print the numbers using a C-style loop
# print the numbers using for in loop
# example2 function definition
def example2():
print("Example 2")
# create the fruits list and print it
# update the first element and print the list
# Add to the end of the list
# Add to the beginning of the list
# Add to the second position of the list
# Replace the value of the first element
# using a for in loop to print the elements
# 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 the main function, do not delete!
main()
Last updated