foundation Estimated learning time: 6 hCommon in syllabi

Included in at least one reviewed higher-education syllabus.

2.1 Syntax, types and control flow

You can write a hundred-line script that reads, decides and prints.

Before:00. Orientation & SetupUnlocks:03. Data Handling & Analysis04. Classical AI — Agents, Search & Knowledge Representation

Values, conditions and loops are the floor of Python, and this topic builds enough of it to write a hundred-line script that reads, decides and prints. Everything later — Pandas, PyTorch, agents — is these constructs wearing better clothes. It opens the Python module for that reason. The early surprise is truthiness: empty lists, zero and None all count as false, which reads as convenient right up until it hides a bug.

Work through these

  • Numbers, strings, booleans, None

    The basic value types and the one that represents nothing at all. Everything else in Python is built from these, and the absent value has its own behaviour worth knowing early.

  • Operators, truthiness and comparison chaining

    Operators, which values count as true in a condition, and Python's ability to chain comparisons the way mathematics does. That chaining is unusual and pleasant once you know it exists.

  • if/elif/else, while, for, range

    Making decisions and repeating work are the two control structures nearly every program is built from. Almost everything you will write in this subject is these few patterns combined.

  • break, continue, else-on-loop

    Leaving a loop early, skipping an iteration, and the clause that runs only if the loop was never interrupted. That last one is a Python peculiarity that reads oddly until explained.

Sign in to keep your progress.

Free resources

Links last checked 29 Aug 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.