Get startedGet started for free

The first five prizes with quarter shares

Find the first five prizes with one or more laureates sharing 1/4 of the prize. Project our prize category, year, and laureates' motivations.

This exercise is part of the course

Introduction to MongoDB in Python

View Course

Exercise instructions

  • Save to filter_ the filter document to fetch only prizes with one or more quarter-share laureates, i.e. with a "laureates.share" of "4".
  • Save to projection the list of field names so that prize category, year and laureates' motivations ("laureates.motivation") may be fetched for inspection.
  • Save to cursor a cursor that will yield prizes, sorted by ascending year. Limit this to five prizes, and sort using the most concise specification.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

from pprint import pprint

# Fetch prizes with quarter-share laureate(s)
filter_ = {____: ____}

# Save the list of field names
projection = [____, ____, ____]

# Save a cursor to yield the first five prizes
cursor = db.prizes.find(filter_, projection).____(____).____(5)
pprint(list(cursor))
Edit and Run Code