BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Introduction to MongoDB in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • 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.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# 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)
Kodu Düzenle ve Çalıştır