Bring it all together
You're building a "highlight reel" for a film app that showcases a few top-rated movies. Your goal is to retrieve the top 5 highest-rated movies released after the year 2000, but you only need to display the title and rating; nothing else!
To do this, you'll combine practically everything you've learned in this chapter; good luck! The mov
collection is still available for you to use.
Este ejercicio forma parte del curso
Introduction to MongoDB in Python
Instrucciones del ejercicio
- Fill in the filter so you only retain movies that have a
release_year
after 2000 (use$gt
). - Use projection to include only
"title"
and"rating"
(and exclude"_id"
). - Sort by
"rating"
in descending order and limit the results to the top five.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
top_rated = mov.find(
# Filter for movies released after 2000
____,
# Project only the title and rating (not id)
____
# Sort by rating descending and limit to five results
).sort("____", ____).limit(____)
print(list(top_rated))