Assignment 1
Assignment 1
1 CSCI 115
2 Assignment 1
2.1 Topics: Python Exploration with Data Management
In this assignment, you will create a Python program that manages a database of movies. You will
implement functions
to add, search, update, and delete movie records. Each movie record will be stored as a dictionary
within a list,
simulating a basic database. You will practice using lists, dictionaries, functions, and basic search
algorithms.
Implementing a Print Function (20 Points)
Task: Develop a function named print_movies(movie_db, n) that prints the details of the first
n movies from the provided movie_db list. Your function should format the output in a reader-
friendly manner, displaying each movie’s title, director, year, and genre on separate lines, followed
by a blank line between each movie record. 1) Correctly implementing the function: 15 points
2) Output formatting: 5 points
Your function must take two parameters: the movie database (movie_db) and an integer (n)
indicating the number of movies to print.
If n is greater than the number of movies in the database, your function should gracefully handle
this by printing all available movies without raising an error.
The output should be well-formatted, making it easy to read and distinguish between different
movie records.
Each movie’s details should be printed according to the following format:
Title: [Movie Title]
Director: [Director’s Name]
Year: [Release Year]
Genre: [Genre]
1
2.1.1 Initializing the movie database
[ ]: movie_db = [
{'title': "Inception", 'director': "Christopher Nolan", 'year': 2010,␣
↪'genre': "Science Fiction"},
{'title': "Mad Max: Fury Road", 'director': "George Miller", 'year': 2015,␣
↪'genre': "Action"},
2
Genre: Crime
[1]: # Part 1, write code here
def print_movies(movie_db, n):
pass # replace and write function implementation
3
2.1.10 Example usage:
print(search_by_director(movie_db, ‘Christopher Nolan’))
4
2.1.17 Expected Output:
Movie titled ‘Ghost Movie’ not found in the database.
[4]: #Part 5 write code here
def delete_movie(movie_db, title):
pass # replace and write function implementation