Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is the code I have for a question in my Zybooks lab: moviesDict = {2005: [['Munich','Steven Spielberg']], 2006: [['The Prestige','Christopher Nolan'],['The Departed','Martin Scorsese']], 2007:

Here is the code I have for a question in my Zybooks lab:

moviesDict = {2005: [['Munich','Steven Spielberg']],

2006: [['The Prestige','Christopher Nolan'],['The Departed','Martin Scorsese']],

2007: [['Into the Wild', 'Sean Penn']],

2008: [['The Dark Knight', 'Christopher Nolan']],

2009: [['Mary and Max', 'Adam Elliot']],

2010: [["The King's Speech",'Tom Hooper']],

2011: [['The Artist', 'Michel Hazanavicius'],['The Help', 'Tate Taylor']],

2012: [['Argo', 'Ben Affleck']],

2013: [['12 Years a Slave', 'Steve McQueen']],

2014: [['Birdman', 'Alejandro G. Inarritu']],

2015: [['Spotlight', 'Tom McCarthy']],

2016: [['The BFG', 'Steven Spielberg']]}

year = int(input("Enter a year between 2005 and 2016: "))

if(year<2005 or year>2016):

print("N/A") if 2005 <= request_year <= 2016:

if (request_year != 2006) and (request_year != 2011) :

movie_list = movie_dict[request_year]

print('%s, %s' % (movie_list[0], movie_list[1]))

if (request_year == 2006) or (request_year == 2011):

movie_list = movie_dict[request_year]

print('%s, %s' % (movie_list[0], movie_list[1]))

print('%s, %s' % (movie_list[2], movie_list[3]))

else: print('N/A')

var = 1 while var==1:

print("Sort by: y - Year d - Director t - Movie title q - Quit")

option = input("Choose an option:")

if(option == 'y'):

for key in sorted(moviesDict.keys()):

print(key,end=':')

for movie in moviesDict[key]:

print("\t",movie[0],",",movie[1])

elif(option == 'd'):

dirDict = {} for key in sorted(moviesDict.keys()):

for movie in moviesDict[key]:

dire = movie[1]

if dire in dirDict:

dirDict[dire].append([movie[0],key])

else: dirDict[dire] = [[movie[0],key]]

for key in sorted(dirDict.keys()):

print(key,end=':')

for dire in dirDict[key]:

print("\t",dire[0],",",dire[1])

elif(option == 't'):

titleDict = {}

for key in sorted(moviesDict.keys()):

for movie in moviesDict[key]:

title = movie[0]

if title in titleDict:

titleDict[title].append([movie[1],key])

else: titleDict[title] = [[movie[1],key]]

for key in sorted(titleDict.keys()):

print(key,end=':')

for title in titleDict[key]:

print("\t",title[0],",",title[1])

elif(option == 'q'):

break;

else:

print("Invalid option")

When I submit it I get this as the response to the Python program within Zylabs:

Submitted: 04:41 pm on 10/15/17

Total: 0 / 12

1 . Compare output

0 / 2

Input

2011

Your output starts with

File "main.py", line 67 elif(option == 'd'): ^ SyntaxError: invalid syntax

Expected output starts with

Enter a year between 2005 and 2016: The Artist, Michel Hazanavicius The Help, Tate Taylor

2 . Compare output

0 / 1

Input

2007

Your output starts with

File "main.py", line 67 elif(option == 'd'): ^ SyntaxError: invalid syntax

Expected output starts with

Enter a year between 2005 and 2016: Into the Wild, Sean Penn

3 . Compare output

0 / 1

Input

2001

Your output starts with

File "main.py", line 67 elif(option == 'd'): ^ SyntaxError

Expected output starts with

Enter a year between 2005 and 2016: N/A

4 . Compare output

0 / 1

Input

2015 q

Your output

File "main.py", line 67 elif(option == 'd'): ^ SyntaxError: invalid syntax

Expected output

Enter a year between 2005 and 2016: Spotlight, Tom McCarthy MENU Sort by: y - Year d - Director t - Movie title q - Quit Choose an option:

5 . Compare output

0 / 2

Input

2014 y q

Your output

File "main.py", line 67 elif(option == 'd'): ^ SyntaxError: invalid syntax

Expected output

Enter a year between 2005 and 2016: Birdman, Alejandro G. Inarritu MENU Sort by: y - Year d - Director t - Movie title q - Quit Choose an option: 2005: Munich, Steven Spielberg 2006: The Prestige, Christopher Nolan The Departed, Martin Scorsese 2007: Into the Wild, Sean Penn 2008: The Dark Knight, Christopher Nolan 2009: Mary and Max, Adam Elliot 2010: The King's Speech, Tom Hooper 2011: The Artist, Michel Hazanavicius The Help, Tate Taylor 2012: Argo, Ben Affleck 2013: 12 Years a Slave, Steve McQueen 2014: Birdman, Alejandro G. Inarritu 2015: Spotlight, Tom McCarthy 2016: The BFG, Steven Spielberg MENU Sort by: y - Year d - Director t - Movie title q - Quit Choose an option:

6 . Compare output

0 / 3

Input

2008 d q

Your output

File "main.py", line 67 elif(option == 'd'): ^ SyntaxError: invalid syntax

Expected output

Enter a year between 2005 and 2016: The Dark Knight, Christopher Nolan MENU Sort by: y - Year d - Director t - Movie title q - Quit Choose an option: Adam Elliot: Mary and Max, 2009 Alejandro G. Inarritu: Birdman, 2014 Ben Affleck: Argo, 2012 Christopher Nolan: The Prestige, 2006 The Dark Knight, 2008 Martin Scorsese: The Departed, 2006 Michel Hazanavicius: The Artist, 2011 Sean Penn: Into the Wild, 2007 Steve McQueen: 12 Years a Slave, 2013 Steven Spielberg: Munich, 2005 The BFG, 2016 Tate Taylor: The Help, 2011 Tom Hooper: The King's Speech, 2010 Tom McCarthy: Spotlight, 2015 MENU Sort by: y - Year d - Director t - Movie title q - Quit Choose an option:

7 . Compare output

0 / 2

Input

2012 t q

Your output

File "main.py", line 67 elif(option == 'd'): ^ SyntaxError: invalid syntax

Expected output

Enter a year between 2005 and 2016: Argo, Ben Affleck MENU Sort by: y - Year d - Director t - Movie title q - Quit Choose an option: 12 Years a Slave: Steve McQueen, 2013 Argo: Ben Affleck, 2012 Birdman: Alejandro G. Inarritu, 2014 Into the Wild: Sean Penn, 2007 Mary and Max: Adam Elliot, 2009 Munich: Steven Spielberg, 2005 Spotlight: Tom McCarthy, 2015 The Artist: Michel Hazanavicius, 2011 The BFG: Steven Spielberg, 2016 The Dark Knight: Christopher Nolan, 2008 The Departed: Martin Scorsese, 2006 The Help: Tate Taylor, 2011 The King's Speech: Tom Hooper, 2010 The Prestige: Christopher Nolan, 2006 MENU Sort by: y - Year d - Director t - Movie title q - Quit Choose an option:

I desperately need some help to get through this lab. Python has been kicking my butt with my lack of experience in coding and I only have two weeks left for my class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

WHAT IS AUTOMATION TESTING?

Answered: 1 week ago

Question

What is Selenium? What are the advantages of Selenium?

Answered: 1 week ago

Question

Explain the various collection policies in receivables management.

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago