Activity 1.30
Source Code
import random
def main():
done = False
while not done:
print("Menu System")
print("E1 - Example 1")
print("P1 - Problem 1")
print("P2 - Problem 2")
print("Q - Quit")
choice = input("Choice: ")
if choice == "E1":
# example1 function call
example1()
elif choice == "P1":
print("Problem 1")
elif choice == "P2":
print("Problem 2")
elif choice == "Q":
print("Quitting!")
done = True
else:
print("Invalid choice")
# example1 function definition
def example1():
print("Example 1")
# create a list of the first 10 numbers
numbers = []
for x in range(1, 11):
numbers.append(x)
# print the index and values
print("Index\tValue")
for x in range(len(numbers)):
print(str(x) + "\t" + str(numbers[x]))
# remove the last element
# remove the second element
# remove the second element
# problem1 function definition
# problem2 function definition
# call the main function, do not delete!
main()
Last updated