Question

In: Computer Science

In Python Modify the program so it contains four columns: name, year, price and rating (G,PG,R…)...

In Python

  • Modify the program so it contains four columns: name, year, price and rating (G,PG,R…)
  • Enhance the program so it provides a find by rating function that lists all of the movies that have a specified rating

def list(movie_list):
if len(movie_list) == 0:
print("There are no movies in the list.\n")
return
else:
i = 1
for row in movie_list:
print(str(i) + ". " + row[0] + " (" + str(row[1]) + ")")
i += 1
print()

def add(movie_list):
name = input("Name: ")
year = input("Year: ")
movie = []
movie.append(name)
movie.append(year)
movie_list.append(movie)
print(movie[0] + " was added.\n")   

def delete(movie_list):
number = int(input("Number: "))
if number < 1 or number > len(movie_list):
print("Invalid movie number.\n")
else:
movie = movie_list.pop(number-1)
print(movie[0] + " was deleted.\n")
  
def display_menu():
print("COMMAND MENU")
print("list - List all movies")
print("add - Add a movie")
print("del - Delete a movie")
print("exit - Exit program")
print()

def main():
movie_list = [["Monty Python and the Holy Grail", 1975],
["On the Waterfront", 1954],
["Cat on a Hot Tin Roof", 1958]]

display_menu()
  
while True:
command = input("Command: ")
if command == "list":
list(movie_list)
elif command == "add":
add(movie_list)
elif command == "del":
delete(movie_list)
elif command == "exit":
break
else:
print("Not a valid command. Please try again.\n")
print("Bye!")

if __name__ == "__main__":
main()

I just don't get how to modify it. Any help will be appreciated!

Solutions

Expert Solution

Please find the answer below.Given code is in python, Hence indentation is very important . Make sure you are
referring screenshot to match indentation after coping the code.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.

def list(movie_list):
if len(movie_list) == 0:
print("There are no movies in the list.\n")
return
else:
i = 1
for row in movie_list:
print(str(i) + ". " + row[0] + " (" + str(row[1]) + ") Rate : "+str(row[3])+" @ $"+str(row[2]))
i += 1
print()

def add(movie_list):
name = input("Name : ")
year = input("Year : ")
price = input("Price : ")
rating = input("Rating : ")
movie = []
movie.append(name)
movie.append(year)
movie.append(price)
movie.append(rating)
movie_list.append(movie)
print(movie[0] + " was added.\n")   

def delete(movie_list):
number = int(input("Number: "))
if number < 1 or number > len(movie_list):
print("Invalid movie number.\n")
else:
movie = movie_list.pop(number-1)
print(movie[0] + " was deleted.\n")
  
def display_menu():
print("COMMAND MENU")
print("list - List all movies")
print("add - Add a movie")
print("del - Delete a movie")
print("exit - Exit program")
print()

def main():
movie_list = [["Monty Python and the Holy Grail", 1975,190.90,"G"],
["On the Waterfront", 1954,3190.90,"A"],
["Cat on a Hot Tin Roof", 1958,1490.90,"PG"]]
  
display_menu()
  
while True:
command = input("Command: ")
if command == "list":
list(movie_list)
elif command == "add":
add(movie_list)
elif command == "del":
delete(movie_list)
elif command == "exit":
break
else:
print("Not a valid command. Please try again.\n")
print("Bye!")

if __name__ == "__main__":
main()


Related Solutions

Modify the Movie List 2D program -Modify the program so it contains four columns: name, year,...
Modify the Movie List 2D program -Modify the program so it contains four columns: name, year, price and rating (G,PG,R…) -Enhance the program so it provides a find by rating function that lists all of the movies that have a specified rating def list(movie_list): if len(movie_list) == 0: print("There are no movies in the list.\n") return else: i = 1 for row in movie_list: print(str(i) + ". " + row[0] + " (" + str(row[1]) + ")") i += 1...
PYTHON Modify the program in section Ask the user for a first name and a last...
PYTHON Modify the program in section Ask the user for a first name and a last name of several people.  Use a loop to ask for user input of each person’s first and last names  Each time through the loop, use a dictionary to store the first and last names of that person  Add that dictionary to a list to create a master list of the names  Example dictionary: aDict = { "fname":"Douglas", "name":"Lee" } ...
[PYTHON] Modify the examaverages.py program included with this assignment so it will also compute the overall...
[PYTHON] Modify the examaverages.py program included with this assignment so it will also compute the overall average test grade. E.g if there are 3 test each student must take and the user enters the following set of test scores for the two students…: 30, 40, 50 for the first student 50, 60, 70 for the second student …then program will print the average for each student (i.e. 40 for the first student and 60 for the second student – the...
In python....Modify the recursive Fibonacci program given in the textbook so that it prints tracing information....
In python....Modify the recursive Fibonacci program given in the textbook so that it prints tracing information. Specifically, have the function print a message when it is called and when it returns. For example, the output should contain lines like these: Computing fib(4) OR Leaving fib(4) returning 3
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT