Asking Questions of Data

A dataset is only useful if you can ask it questions:

How many books are there? Which were published after 1800? Which is the oldest? Who wrote the most?

Right now you can answer these by hand, record by record. In Module 12 you'll learn loops and answer them for a million records with the same four lines. Today, build the instinct.

EXAMPLE
loading editor…
YOUR TURN
Your turn → Comparisons from Module 6 now do real analytical work. Write a check for whether Kindred came out before Beloved.
loading editor…

Syntax has to be exact. Every quote, bracket and parenthesis needs its partner, and in Python the spaces at the start of a line count. One slip and the program won't run; the message will say where.

Data gets nested too, a record can contain a list, or another record. Reach in the same way: one layer at a time.

EXAMPLE
loading editor…
YOUR TURN
Your turn → Print how many years the principal has served. Then print the last student in the list.
loading editor…

Syntax has to be exact. Every quote, bracket and parenthesis needs its partner, and in Python the spaces at the start of a line count. One slip and the program won't run; the message will say where.

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Building and Growing a Dataset →
← Back