Kids Coding

Data Tables

A list of dictionaries is a tiny table. Loop, filter, and print a report.

KidsAdvancedData Tables

A table is a list of dicts

Each dict is a row. Each key is a column. Loop the list. Read the keys you need.

Scores

rows = [
    {"name": "Sam", "score": 12},
    {"name": "Riley", "score": 8},
    {"name": "Jun", "score": 15},
]

for row in rows:
    print(row["name"], row["score"])

A list of dictionaries is the shape of almost every real dataset: one dictionary per row, the same keys on every row.

Filter

High scores

rows = [
    {"name": "Sam", "score": 12},
    {"name": "Riley", "score": 8},
    {"name": "Jun", "score": 15},
]

for row in rows:
    if row["score"] >= 10:
        print(row["name"], "passed")

Real life

A class mark sheet: name in one column, score in the next.

Each row is a dict. The list is the sheet. Loop it like reading down the page.

Class marks

sheet = [
    {"name": "Sam", "mark": 18},
    {"name": "Riley", "mark": 12},
    {"name": "Jun", "mark": 20},
]
for row in sheet:
    if row["mark"] >= 15:
        print(row["name"], "passed")

Change one word. Run it. That is how this idea shows up outside the lesson.

Try it

Exercise 1: Loop a list of two dicts with city and print each city.

Show solution
rows = [
    {"city": "Lisbon"},
    {"city": "Oslo"},
]
for row in rows:
    print(row["city"])

FAQ: Data Tables

Common questions about this page.

What is StudyGrid Kids?

StudyGrid Kids is a free coding path for children: Basic, Intermediate, and Advanced. Lessons use Python in the browser. No account and no install.

Should I run data tables examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn data tables in this Kids Coding Python lesson (Data Tables).

Which kids level should we start with?

Start at Basic if the child has never written code. Choose Intermediate if they can print, use variables, and write a simple if. Choose Advanced if they already use loops and lists.

Do kids need an account or an app?

No. Kids pages are public. Code runs in the Try Python editor at /try. We do not ask children for a name or an email.

What language do kids learn?

Python, with a first HTML page in Intermediate and Advanced. After Advanced, the main Python tutorial is the next step.

Is the kids coding track free?

Yes. The Kids home, the three levels, and the Python editor on StudyGrid (studygrid.in) are free.