Activity 2.7
Source Code
def main():
# dictionary of towns in Passaic with population
passaicCountyTowns = {
"Paterson": 145000,
"Clifton": 85000,
"Passaic": 70000,
"Wayne": 55000,
"West Milford": 26000,
"Hawthorne": 19000,
"Little Falls": 15000,
"Pompton Lakes": 11000
}
# dictionary of towns in Bergen with population
bergenCountyTowns = {
"Hackensack": 44000,
"Teaneck": 40000,
"Fort Lee": 37000,
"Fair Lawn": 33000,
"Paramus": 26000,
"Lodi": 24000,
}
done = False
while not done:
print("Menu System")
print("E1 - Example 1")
print("Q - Quit")
choice = input("Choice: ").upper()
if choice == "E1":
# Passaic County Towns and Populations
print("Passaic County Towns and Populations")
print("Total: " + str(example1(passaicCountyTowns)))
print()
# Bergen County Towns and Populations
print("Bergen County Towns")
print("Total: " + str(example1(bergenCountyTowns)))
elif choice == "P1":
problem1()
elif choice == "P2":
problem2()
elif choice == "P3":
problem3()
elif choice == "P4":
problem4()
elif choice == "Q":
print("Quitting!")
done = True
else:
print("Invalid choice")
# example1 function definition
def example1(towns):
print("Example 1")
# empty list
# add header and for loop
# print the sum of the towns
# return the sum of the population
# problem1
def problem1():
pass
# problem2
def problem2():
pass
# problem3
def problem3():
pass
# problem4
def problem4():
pass
# call the main function, do not delete!
main()
Last updated