The family Python path
Learn Python.
Make it yours.
Start where you are. Work at your own pace, use the lessons and activities, and move on when you can explain and use the idea.
Choose your own paceNew to programming? Start with step 1. If you already know the basics, open a step and try its challenge. Each step builds on the ones before it. Use your own editor to run the code and save your work.
STEP 01PYTHON
First steps
Run Python, use print(), explore numbers and text, and save a program.
Open this step +
Learn: A program is a set of instructions. Python reads them from top to bottom. Text inside quotes is called a string.
print("Hello, world!")
print(2 + 3)
Practice: Save this as hello.py and run it. Change the message. Predict the result of changing + to *.
Think about it: What happens if you remove a closing quote? Put it back and run again.
Project: Make a three-line introduction. Change one line and predict what will happen.
Ready to move on? Explain what a program and an error message are.
STEP 02PYTHON
Variables & input
Store text and numbers, name variables, use input(), and convert types.
Open this step +
Learn: A variable gives a value a name. input() reads text from the keyboard; int() converts whole-number text to a number.
name = input("Your name: ")
age = int(input("Your age: "))
print("Hello,", name)
print("Next year:", age + 1)
Practice: Make a program that asks for a favorite animal and prints a message about it.
Think about it: Why does age + 1 need int()? What happens if you type a word instead of a number?
Project: Create a greeting that asks for a name and favorite activity.
Ready to move on? Explain why input is text and convert a number safely.
STEP 03PYTHON
Decisions
Compare values and combine conditions with if, elif, and else.
Open this step +
Learn: A condition is either True or False. Indented lines run only when their condition matches.
score = 7
if score >= 10:
print("Level up!")
else:
print("Keep going!")
Practice: Ask for a number and tell the player whether it is greater than, less than, or equal to 10.
Think about it: Try 9, 10, and 11. Does each path work?
Project: Make a choose-your-own-path scene with at least two choices.
Ready to move on? Trace which branch runs for three different inputs.
STEP 04PYTHON
Loops
Repeat work with for, range, and while; use break with care.
Open this step +
Learn: A for loop repeats once for each item. range(3) produces 0, 1, 2. A while loop keeps going while a condition is true.
for turn in range(3):
print("Turn", turn + 1)
Practice: Print a countdown from 5 to 1, then print “Go!” Try it with a while loop too.
Think about it: What must change inside a while loop so it can stop?
Project: Build a guessing game with a limited number of attempts.
Ready to move on? Explain when a loop stops and fix an endless loop.
STEP 05PYTHON
Functions
Define functions, pass arguments, return values, and keep tasks small.
Open this step +
Learn: Functions collect instructions under a name. Parameters receive inputs; return sends a value back.
def double(number):
return number * 2
result = double(4)
print(result)
Practice: Write a function that takes a name and returns a greeting. Call it with two different names.
Think about it: What is the difference between returning a value and printing it?
Project: Turn a game’s greeting and scoring into separate functions.
Ready to move on? Describe the difference between printing and returning.
STEP 06PYTHON
Collections
Use lists and dictionaries to store, find, and change related data.
Open this step +
Learn: A list holds a sequence. A dictionary connects keys to values. Indexes start at zero.
inventory = ["map", "torch"]
inventory.append("key")
print(inventory[0])
player = {"name": "Alex", "score": 3}
print(player["score"])
Practice: Create an inventory with three items. Add one and print each item with a loop.
Think about it: What happens if you ask for a list index that does not exist?
Project: Make an inventory that can add and display items.
Ready to move on? Choose a list or dictionary and explain why.
STEP 07PYTHON
Text & files
Work with strings, read and write text, and handle common errors.
Open this step +
Learn: Strings can be changed with methods. Files let a program keep information after it ends. The with statement closes a file when finished.
message = " Hello there "
print(message.strip().upper())
with open("note.txt", "w", encoding="utf-8") as file:
file.write("A note to my future self.")
Practice: Run this in a practice folder. Open note.txt and change the program to write your own message.
Think about it: The w mode replaces an existing file. How would that affect a file you care about?
Project: Save a short journal entry and read it back.
Ready to move on? Explain where a file is saved and handle a missing file.
STEP 08PYTHON
Game design
Use random choices, player input, rules, and game state.
Open this step +
Learn: Games combine rules, state, and decisions. Random values make each round different.
import random
secret = random.randint(1, 5)
guess = int(input("Guess 1–5: "))
if guess == secret:
print("You got it!")
else:
print("The number was", secret)
Practice: Add a second chance. Then tell the player if the guess was too high or too low.
Think about it: Play several rounds. What happens if someone enters text?
Project: Design an original word or number game; playtest with family.
Ready to move on? Explain the rules and fix one issue found in testing.
STEP 09PYTHON
Graphics & events
Explore drawing, coordinates, event handling, and animation.
Open this step +
Learn: A coordinate tells a drawing where to go. Python’s turtle module can draw lines as a cursor moves.
import turtle
pen = turtle.Turtle()
for side in range(4):
pen.forward(100)
pen.right(90)
turtle.done()
Practice: Run this on a computer with a graphical desktop and turtle support. Change the color and turn the square into another pattern.
Think about it: How many sides and what turn angle would make an equilateral triangle?
Project: Create a moving shape or small interactive scene using a local graphics library.
Ready to move on? Explain how an event changes the program’s state.
STEP 10PYTHON
Classes & objects
Group data and behavior; create instances and use methods.
Open this step +
Learn: A class describes a kind of object. Each object has its own data, and methods describe what it can do.
class Pet:
def __init__(self, name):
self.name = name
self.energy = 3
def play(self):
self.energy -= 1
rex = Pet("Rex")
rex.play()
print(rex.name, rex.energy)
Practice: Make two pets with different names. Add a rest method that increases energy.
Think about it: After one pet plays, does the other pet’s energy change? Why?
Project: Model a pet, player, or inventory item with a class.
Ready to move on? Create two objects and explain how their state differs.
STEP 11PYTHON
Data & practical tools
Explore JSON, CSV, APIs, and separating data from presentation.
Open this step +
Learn: CSV stores rows of data. The standard csv module reads them without manually splitting commas.
import csv
from io import StringIO
data = StringIO("item,count\napples,3\npears,2\n")
for row in csv.DictReader(data):
print(row["item"], row["count"])
Practice: Change the sample data and write code that totals the counts using int().
Think about it: What should your program do if a count is blank?
Project: Read a small CSV and display a useful summary.
Ready to move on? Handle an empty input and explain the result.
STEP 12PYTHON
Build & share
Plan, write, test, document, and revise a complete project.
Open this step +
Learn: A finished project needs a clear goal, small steps, tests, and instructions for someone else.
# Start a new project here.
# 1. Describe what it should do.
# 2. List the smallest working features.
# 3. Build and test one feature at a time.
print("My project starts here!")
Practice: Choose a game or useful tool. Build a first version, ask someone to try it, and improve one thing.
Think about it: Can another person run it using your instructions? What would you build next?
Project: Choose a game or useful tool; write a README and demonstrate it.
Ready to move on? Show a working project, explain a bug you fixed, and suggest an improvement.