First programs

What a program is, how Python stores values, how it does arithmetic, and how to read input and show results neatly.

About 7 hours of study

Learning objectives

Lessons

  1. 1

    Your first program

    Print text and numbers, write comments, and watch Python run from top to bottom.

  2. 2

    Variables and assignment

    Store values in names, update them, and see what Python does at each line.

  3. 3

    Numbers and operators

    Add, divide, find remainders and powers, and learn which operator Python works out first.

  4. 4

    Input and type conversion

    Read what the user types, turn text into numbers, and print neat results with f-strings.

  5. 5

    Formatting output

    Line up columns, round numbers and add separators with f-string format codes.

Module practice

Module quiz

1. What does print("5" * 3) show?
2. After x = 2 and x = x * 3, what is x?
3. What is 7 % 3?
4. A user types 12. What is the result of input() + "1"?
5. What does f"{3.14159:.2f}" produce?
6. Which expression gives the last digit of a whole number n?

Decisions and loops ›