2.4 Movie ratings

You have three parallel arrays: one stores movie titles, one stores their genres, and one stores their ratings (out of 10). Ask the user to enter a target genre and a minimum rating. Count how many movies are in that genre and have a rating greater than or equal to the minimum rating. Display the total, and also show the names of the matching movies.

movies = ["Sky Rush", "Hidden Lake", "Thunder Road", "Quiet Night", "Steel Force", "Green Fields"]
genres = ["action", "drama", "action", "drama", "action", "comedy"]
ratings = [8, 6, 7, 9, 5, 7]
Enter a genre: action
Enter a minimum rating (0–10): 7

Number of action movies rated at least 7: 2
Matching movies:
Sky Rush
Thunder Road
set movies to ["Sky Rush", "Hidden Lake", "Thunder Road", "Quiet Night", "Steel Force", "Green Fields"]
set genres to ["action", "drama", "action", "drama", "action", "comedy"]
set ratings to [8, 6, 7, 9, 5, 7]

ask user for target genre and store in target_genre
ask user for minimum rating and store in min_rating

output blank line

set count to 0

loop for length of movies array
    if genre at current position equals target_genre AND rating at current position >= min_rating
        set count to count + 1

print "Number of", target_genre, "movies rated at least", min_rating, ":", count

print "Matching movies:"
loop for length of movies array
    if genre at current position equals target_genre AND rating at current position >= min_rating
        print movie at current position
movies = ["Sky Rush", "Hidden Lake", "Thunder Road", "Quiet Night", "Steel Force", "Green Fields"]
genres = ["action", "drama", "action", "drama", "action", "comedy"]
ratings = [8, 6, 7, 9, 5, 7]

target_genre = input("Enter a genre: ")
min_rating = int(input("Enter a minimum rating (0–10): "))

print()

count = 0
for i in range(len(movies)):
    if genres[i] == target_genre and ratings[i] >= min_rating:
        count = count + 1

print("Number of " + target_genre + " movies rated at least " + str(min_rating) + ": " + str(count))

print("Matching movies:")
for i in range(len(movies)):
    if genres[i] == target_genre and ratings[i] >= min_rating:
        print(movies[i])
# Parallel arrays: titles, genres, and ratings at the same positions
movies = ["Sky Rush", "Hidden Lake", "Thunder Road", "Quiet Night", "Steel Force", "Green Fields"]
genres = ["action", "drama", "action", "drama", "action", "comedy"]
ratings = [8, 6, 7, 9, 5, 7]

# Get the target filters from the user
target_genre = input("Enter a genre: ")
min_rating = int(input("Enter a minimum rating (0–10): "))

print()  # Blank line after inputs

# Count how many movies meet the condition
count = 0
for i in range(len(movies)):
    if genres[i] == target_genre and ratings[i] >= min_rating:
        count = count + 1

# Display the total
print("Number of " + target_genre + " movies rated at least " + str(min_rating) + ": " + str(count))

# Display the matching movie titles
print("Matching movies:")
for i in range(len(movies)):
    if genres[i] == target_genre and ratings[i] >= min_rating:
        print(movies[i])

Extension

If no movies match the chosen genre and rating, the program should display a clear message saying

“No movies found”

instead of showing

“Matching movies:” with nothing underneath.

Enter a genre: comedy
Enter a minimum rating (0–10): 9

Number of comedy movies rated at least 9: 0
No movies found