Activity 2.2
Source Code
import random
def main():
done = False
while not done:
print("Menu System")
print("E1 - Example 1")
print("Q - Quit")
choice = input("Choice: ")
if choice == "E1":
example1()
elif choice == "Q":
print("Quitting!")
done = True
else:
print("Invalid choice")
# example1 function definition
def example1():
print("Example 1")
# 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 the list
for p in popular_movies:
print(p)
# print a random movie
# in operator
# call the main function, do not delete!
main()
playlist.py
import random
def main():
# feel free to add initial songs
playlist = []
done = False
while not done:
print("Spotify Playlist Manager")
print("1. Add a song")
print("2. Remove a song")
print("3. View playlist")
print("4. Select a random song")
print("5. Sort playlist")
print("6. Clear playlist")
print("7. Exit")
choice = input("Choose an option (1-6): ")
if choice == "1":
print("Add a song")
elif choice == "2":
print("Remove a movie")
elif choice == "3":
print("My current playlist")
elif choice == "4":
print("Here's a random song!")
elif choice == "5":
print("Sort my playlist alphabetically")
elif choice == "6":
playlist.clear()
print("Playlist cleared.")
elif choice == "7":
print("Goodbye!")
done = True
else:
print("Invalid choice. Please try again.")
main()
Last updated