Skip to main content

Python Programming Study Guide

The whole course, unit by unit

Eight units from first syntax through data science and visualization to AI/ML readiness. Each unit explains what to know, how to apply it, what typically goes wrong, and one study move that makes the material stick.

Eight units

Foundations, functions and design, collections and algorithms, object-oriented Python, files and APIs, data science, visualization, then AI/ML readiness.

No single exam

This is a school and enrichment course rather than a College Board one, so assessment is by projects, quizzes, and implementation work.

Wide entry range

Suitable from middle school through college. Units 1 to 4 assume no prior programming; Units 6 to 8 assume comfort with functions and collections.

Where it leads

AP Computer Science Principles, data science coursework, and the AI/ML course.

Units

The eight units

Unit 1 is the largest by a wide margin. The rest move faster, and the last one is the bridge into calculus.

1

Unit 1 · Foundational

Python Foundations

Variables, types, operators, and control flow. Python hides type declarations, which makes the language friendly to start and makes type errors appear later than they would elsewhere.

Dynamic typingBindingFloor divisionImmutabilityf-stringIndentation block
2

Unit 2 · Foundational

Functions and Program Design

Decomposition, and the scope rules that make it safe. This is the unit that decides whether later programs stay readable as they grow.

ParameterArgumentReturnLocal scopeGlobal scopeDefault argument
3

Unit 3 · Heavy

Collections and Algorithms

The four built-in collections and the habit of choosing between them. Most of the awkwardness in beginner Python comes from solving a dictionary problem with parallel lists.

ListSliceDictionaryHashableSetTuple
4

Unit 4 · Moderate

Object-Oriented Python

Classes in a language with no enforced privacy. Encapsulation here is a convention the programmer upholds rather than a rule the language imposes, which changes how it must be taught.

ClassInstanceInitialiserInstance attributeClass attributeSpecial method
5

Unit 5 · Moderate

Files, APIs, and Automation

Where Python stops being an exercise and starts touching real data. The unit adds a new category of failure: the input may be missing, malformed, or unavailable, and correct code has to survive that.

Context managerCSVJSONAPIStatus codeException
6

Unit 6 · Heavy

Data Science With Python

NumPy and pandas, and the shift from writing loops to describing operations on whole columns. Most of the difficulty is not syntax but knowing what a dataset actually contains before analysing it.

NumPy arrayVectorisedDataFrameLabel selectionMissing valueGroup by
7

Unit 7 · Moderate

Visualization and Communication

Turning an analysis into something another person can read and trust. The technical content is small; the judgement about honest presentation is the substance.

Chart typeAxis labelBaselineTruncated axisSpreadSample size
8

Unit 8 · Bridge unit

AI/ML Readiness

The bridge into the AI/ML course. It establishes the workflow and vocabulary rather than the models themselves, so a student arrives able to prepare data and judge a result.

FeatureLabelData leakageTrain/test splitBaselineClass imbalance

Mathematical Practices

The habits that run through every unit

Four habits that decide whether Python code stays correct and readable as a program grows.

1. Choose the structure first

Before writing a loop, ask whether the data is a list, a dictionary, or a set. A great deal of awkward Python is a dictionary problem being solved with two parallel lists.

2. Read the error message

Python errors name the type, the line, and usually the cause. Reading the last line of a traceback before changing anything is the fastest debugging habit available in this language.

3. Test at the boundary

Empty list, single element, missing key, and an off-by-one slice are where Python code breaks. A function that works on a five-item example has not been tested.

4. Name things honestly

Python code is read far more than it is written, and a name that describes the content is worth more than a comment explaining a name that does not.

Assessment

How to answer, not only what to know

Two lists: one for selected-response work, one for anything you have to write out.

Multiple choice

  • Check whether an operation mutates or returns. Sorting a list in place and returning a sorted copy are different calls with different results.
  • On slicing questions, mark the start and stop indices explicitly; the stop is excluded.
  • For dictionary questions, decide first whether a missing key should raise or return a default.
  • Watch for integer versus float division. The two division operators behave differently and both appear in questions.
  • On mutability questions, ask whether two names refer to the same object. Lists and dictionaries are shared by reference.

Written work

  • Return values rather than printing them unless the task explicitly asks for output.
  • Handle the empty input case, which is the most commonly omitted branch.
  • Choose the data structure that makes the solution short, then say in a comment why it fits.
  • Keep functions small enough to describe in one sentence; a function that needs a paragraph should be split.
  • When reading a file or an API, handle the case where the data is missing or malformed.

Study plan

Where the time is best spent

Four moves, in the order that pays off.

1

Get fluent with lists and dictionaries

These two structures carry most of the course. Being able to choose between them without thinking is the single highest-value early skill.

2

Write functions early

Decomposition is what separates a script that grows unmanageable from one that stays workable. Practise splitting before it hurts.

3

Read tracebacks properly

Spend a session deliberately causing and reading errors: type errors, key errors, index errors. Recognising them on sight saves hours later.

4

Build something small end to end

A program that reads data, processes it, and reports a result exercises Units 1 to 5 together and exposes gaps that unit-by-unit practice hides.

5

Move to real data

Units 6 and 7 are where Python starts paying off. Work with a messy dataset rather than a tidy teaching one.

6

Bridge into AI/ML deliberately

Unit 8 is preparation, not the destination. Arrive with confident pandas and plotting rather than rushing to models.

Curriculum scope

What this sequence includes

Python is taught here as a tool for expressing a solution clearly, not as a list of syntax rules. The recurring question across every unit is which data structure represents the problem, because in Python that choice determines how short and how readable the rest of the solution is.

Algebra and trigonometry core

Essential foundations

  • Variables, dynamic typing, operators, and control flow
  • Functions, parameters, return values, scope, and program decomposition
  • Lists, dictionaries, sets, tuples, and choosing between them
  • Iteration patterns, comprehensions, and standard algorithms
  • Classes, objects, attributes, methods, and encapsulation in a dynamically typed language
  • Reading and writing files, consuming APIs, and automating repetitive work

Breadth beyond the assessed core

Included in this sequence

  • NumPy arrays and pandas DataFrames for tabular data
  • Exploratory analysis, cleaning, and summarising a dataset
  • Plotting and the honest presentation of results
  • The vocabulary and workflow that the AI/ML course builds on

Varies by course

Compare with the school syllabus

  • Pacing. A middle school section may spend most of a year in Units 1 to 3; an older student may reach Unit 6 in a term.
  • Virtual environments. Taught where students install packages locally, skipped where the course runs in a browser.
  • Type hints. Increasingly common in class code, though not required to write correct Python.
  • Testing frameworks. Some sections introduce pytest; others test by assertion and inspection.

Glossary

Terms worth being precise about

Dynamic typing

Types belong to objects rather than to names, so a name may refer to different types over time.

Mutability

Whether an object can be changed in place. Lists, dictionaries, and sets can; strings and tuples cannot.

Comprehension

A compact expression that builds a list, dictionary, or set from an iterable.

Slice

A sub-sequence selected by start, stop, and step, where the stop index is excluded.

Traceback

The error report naming the exception type, the line, and the call path that reached it.

Key error

The exception raised when a dictionary is asked for a key it does not hold.

Module

A file of Python definitions imported for reuse.

DataFrame

The pandas table structure with labelled rows and columns.

Vectorised operation

An operation applied across a whole array or column at once rather than element by element in a loop.