ComenzarEmpieza gratis

The $or operator

You want to create a list of high-quality movies and want to design criteria for your selection: the movie needs to have won an Academy Award (also known as an Oscar), or have a rating higher than 7.5. As well as the $or operator, you will need the $gte operator, short for greater than or equal to.

Este ejercicio forma parte del curso

Introduction to MongoDB in Python

Ver curso

Instrucciones del ejercicio

  • Complete the oscar filter on "won_oscar" to reflect the first condition.
  • Complete the high_rating filter on "rating" to reflect the second condition. Use "$gte".
  • Combine the two criteria using $or to find all movies that match one or both of the criteria.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Create the won_oscar filter
oscar = { "____": ____ }

# Create the rating filter
high_rating = { "____": { "____": ____ }}

# Combine with $or
hq_curs = mov.find({
  "____": [
    ____,
    ____
  ]
})
  
# Convert from cursor to list
hq = list(hq_curs)
print(hq)
Editar y ejecutar código