Assignment 3
You have two options for this assignment. You can continue working with the HighestGrossingMovies.json file that we started with in class and write a specified search function for the data. Or, you can choose a new data set and build a custom search application.
Assignment Option 1: Popular Movies by Genre Search
Create a file called popular_movies.py, and write a function in it called most_popular_in_genre. This function should take two parameters:
- A list of dictionaries representing movies like in
HighestGrossingMovies.json(don’t hard-code it to load that file though - somebody might pass a different list of movie record dictionaries to your function) - The name of a genre like “Action”, “Comedy”, or “Drama”. and it should return the movie record from that genre with the highest world sales.
For example, if I tested your code with a call like this
print( most_popular_in_genre(movies,"Comedy") )
it should result in output that looks like this:
{'Title': 'Frozen II (2019)', 'Summary': "Anna, Elsa, Kristoff, Olaf and Sven leave Arendelle to travel to an ancient, autumn-bound forest of an enchanted land. They set out to find the origin of Elsa's powers in order to save their kingdom.", 'Distributor': 'Walt Disney Studios Motion Pictures', 'Release Date': 'November 20, 2019', 'Domestic Sales': 477373578, 'International Sales': 972653355, 'World Sales': 1450026933, 'Genre': "['Adventure', 'Animation', 'Comedy', 'Family', 'Fantasy', 'Musical']", 'Runtime': '1 hr 43 min', 'MPAA Rating': 'PG'}
Submit your popular_movies.py file to the Assignment 3: JSON Search assignment on codePost. Your most_popular_in_genre will be tested with some automated tests.
Assignment Option 2: Creative Project
For this option, you may use any file in .json format that contains nested structures of lists and dictionaries. Create a custom application that allows the user to type in some information and then search for results from the .json file. If you choose this option, I will be looking for a few things:
- At least two well-written functions, with at least one that uses parameters and return values. For instance, you could do the user interaction in one function and the search in another function.
- Well-formatted output - the user shouldn’t see any raw dictionaries being printed with things like brackets (
{,},[,]) and quoted strings. - A big multi-line comment where you show an example run that shows off what your program does.
I suggest looking at Kaggle for interesting data sets. Kaggle will let you search datasets that include the JSON format. However, note that for some data sets, the interesting stuff isn’t actually in the JSON files, so you might need to browse for a JSON file that works for this assignment.
Submit your Python and .json file (if the .json file is too big, instead submit a copy with just some of the data so I can see how it is structured) to the Assignment 3: JSON Search assignment on codePost.
The automated tests are assuming you do Option 1, so if you pick Option 2 you can ignore the errors and the -4 you’ll be getting from the codePost.
Grading
This is a 4-point assignment. See the rubric from the syllabus.