Question
Movie genres represent the various categories that movies can belong to. A movie could be a comedy, a romance, a zombie film, or a romantic
Movie genres represent the various categories that movies can belong to. A movie could be a comedy, a romance, a zombie film, or a romantic zombie comedy. The Movie class defines a constant tuple of genre names called GENRES . The genres for each Movie object is stored as a list of integer indexes for the GENRES constant. Thus a romantic zombie comedy would have its genres stored as [3,4,5] . This list of integers must be converted to a string for display purposes.
For example, the movie Dellamorte, Dellamore has the genre list [3,4,5,8] . It prints out as:
Title: Dellamorte Dellamore Year: 1994 Director: Michele Soavi Rating: 7.2 Genres: romance, comedy, zombie, horror
Complete the genres_string method for the Movie class.
Test Movie.py:
def genres_string(self):
"""
-------------------------------------------------------
Returns comma delimited string of genres based upon the
current movie object's integer genres list.
e.g.: [0, 2] returns "science fiction, drama"
Use: string = movie.genres_string()
-------------------------------------------------------
Returns:
string - string of genres (str)
-------------------------------------------------------
"""
return string
class Movie:
"""
Defines data for a single movie: title, year, director, rating, genres.
"""
# Constants
MIN_RATING = 0
MAX_RATING = 10
FIRST_YEAR = 1888
GENRES = ("science fiction", "fantasy", "drama",
"romance", "comedy", "zombie", "action",
"historical", "horror", "war", "mystery")
# Defines a range of valid integer genre codes:
GENRE_CODES = range(len(GENRES))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started