Py PYTHON · BEGINNER PATH

Think in small steps.

Python is designed to be readable. Start by printing a message, give information a name, then use a condition or a loop to guide what happens.

Three lessons · about 18 minutes0 of 3 complete
LESSON 1 · PRINT A MESSAGE

Ask Python to show its work.

The print() function displays information. Put text in quotation marks and place it between the parentheses. This is a quick way to see what your program is doing.

print("Hello, world!")
print("I am learning Python.")
Small detail: Text needs quotation marks. The parentheses tell Python what information to pass to print.

Quick check: what does print() do?

A small step counts.Try Python in the playground ↗
LESSON 2 · VALUES & VARIABLES

Store something for later.

A variable gives a value a name. Write the name, an equals sign, and the value. Then use the name again wherever that value is useful.

learner = "Sam"
lessons_finished = 1

print("Hello, " + learner)
print(lessons_finished)
Names are your notes: lessons_finished explains more than x. Python uses underscores between words by convention.

Quick check: what does the equals sign do here?

A small step counts.
LESSON 3 · DECISIONS & LOOPS

Repeat a task with a loop.

A for loop runs once for each value it receives. range(1, 4) produces 1, 2, and 3. The indented line belongs to the loop, so it runs three times.

for step in range(1, 4):
    print("Step", step)

Conditions let your program choose a path. The indented block under if runs only when its condition is true.

minutes_left = 5

if minutes_left > 0:
    print("There is time to try again.")
Python uses indentation as structure. Keep the lines inside a loop or condition indented consistently.

Quick check: how many values are in range(1, 4)?

A small step counts.Keep the learning going ↗