Activity 2.26
Source Code
import math
import random
def main():
done = False
while not done:
print("Menu System")
print("E1 - Example 1")
print("Q - Quit")
choice = input("Choice: ").upper()
if choice == "E1":
example1()
elif choice == "E2":
example2()
elif choice == "P1":
problem1()
elif choice == "P2":
problem2()
elif choice == "P3":
problem3()
elif choice == "P4":
problem4()
elif choice == "P5":
problem5()
elif choice == "Q":
print("Quitting!")
done = True
else:
print("Invalid choice")
# example1 function definition
def example1():
print("Example 1")
# create a dictionary named languages
languages = {
"Python": 1991,
"Java": 1995,
"C": 1972,
"C++": 1983,
"Java": 1995,
"JavaScript": 1995,
"Lua": 1993,
"Ruby": 1995,
"Go": 2009,
"Rust": 2010,
"Swift": 2014,
}
# call print_dictionary function
# Remove specific key-value pair and return value
# Delete specific key
# print the average year
# print_dictionary function definition
# problem1
def problem1():
pass # remove
# problem2
def problem2():
pass # remove
# problem3
def problem3():
pass # remove
# problem4
def problem4():
pass # remove
# problem5
def problem5():
pass # remove
# call the main function, do not delete!
main()
contacts.py
import math
import random
def main():
# add initial contacts list
contacts = {}
done = False
while not done:
print("Contact Manager")
print("1. Show All Contacts")
print("2. Add Contact")
print("3. Edit Contact")
print("4. Delete Contact")
print("5. Search Contact")
print("6. Exit")
choice = int(input("Choose an option (1-6): "))
if choice == 1:
print("Show All Contacts")
elif choice == 2:
print("Add Contact")
elif choice == 3:
print("Edit Contact")
elif choice == 4:
print("Delete Contact")
elif choice == 5:
print("Search Contact")
elif choice == 6:
print("Goodbye!")
done = True
else:
print("Invalid choice. Please try again.")
# call the main function
main()
Last updated