CurriculumPython, data & AI · Week 03

Week 03 / Functions · lists · dictionaries · loops · errors

Make Python feel familiar.

The idea

A function names a reusable operation. Lists hold ordered items; dictionaries map names to values. Loops repeat work. Error messages point to where Python could not do what the code asked.

Summarize a list of scores

scores = [12, 8, 15]

def describe(scores):
    total = sum(scores)
    average = total / len(scores)
    return {"count": len(scores), "average": average}

print(describe(scores))

Build it

Work through these steps in your own project. Check them off as you go; your checklist stays in this browser.

What input does your function expect, and what useful result does it return?

Notes save in this browser.