Source Code
session5.py
import random
import math
def main():
myName = "" # add your name
print("Session 5 - " + myName)
print("Menu System")
print("E1 - Example 1")
print("Q - Quit")
choice = input("Choice: ").upper()
if choice == "E1":
print("Example 1")
# example1 function call
elif choice == "E2":
print("Example 2")
# example2 function call
elif choice == "E3":
print("Example 3")
# example3 function call
elif choice == "E4":
# example4 function call
example4()
elif choice == "E5":
# example5 function call
example5()
elif choice == "E6":
# example6 function call
example6()
elif choice == "E7":
# example7 function call
example7()
elif choice == "E8":
# example8 function call
example8()
elif choice == "E9":
# example9 function call
example9()
elif choice == "Q":
print("Quitting!")
else:
print("Invalid choice")
# example1 function definition
# example2 function definition
# example3 function definition
# example4 function definition
def example4():
print("Example 4")
# 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
# example5 function definition
def example5():
print("Example 5")
# 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
# example6 function definition
def example6():
print("Example 6")
# create an empty list
# append numbers to the list
# print the number of elements
# smallest element
# largest element
# sum of the elements
# example7 function definition
def example7():
print("Example 7")
# create a list of the first 10 numbers
# print the index and values
# remove the last element
# remove the second element
# remove the value 5
# example8 function definition
def example8():
print("Example 8")
# create a list
# print the index and values
# count 1's, 2's, 3's
# sort the list in ascending order
# sort the list in desending order
# example9 function definition
def example9():
print("Example 9")
# create a list of 10 movies
popular_movies = [
"Barbie",
"Oppenheimer",
"Spider-Man: No Way Home",
"Top Gun: Maverick",
"Avatar: The Way of Water",
"Guardians of the Galaxy Vol. 3",
"The Super Mario Bros. Movie",
"Joker",
"Everything Everywhere All at Once",
"The Batman"
]
# print a random movie
# in operator
# call the main function, do not delete!
main()Last updated