Variables and print()

What a program and a variable are in Python.

1. What is this?

A program is a list of instructions Python runs top to bottom. A variable is a name bound to a value: name = "Ava" stores the text Ava under name. No declaration keyword is needed. print(...) shows a value in the output so you can inspect it.

2. Why do we use it?

Python scripts automate reports, analyse data, and power backends. Variables hold every intermediate result; print() is how you observe them.

3. Syntax breakdown

  • name = "Ava"

    Creates the variable name holding the string Ava. Strings need quotes.

  • age = 28

    Integers need no quotes.

  • print(f"Hello, {name}")

    f-string: {name} is replaced with the variable's value.

5. Common mistakes

  • Mixing quotes: "Ava' — opening and closing quotes must match.
  • Forgetting the f before an f-string, so {name} prints literally.
  • Indentation errors later: Python uses indentation to group code — keep it consistent.

Practice task

Create city = "Berlin" and print "I live in Berlin." using an f-string.

Hint

city = "Berlin" then print(f"I live in {city}.")

Try it below — tests run automatically when you press Run.

python

Output

Press Run to see output.

Mini quiz

3 questions. Answer, then check.

  1. 1. How do you create a variable in Python?

  2. 2. What does the f in f"Hello {name}" do?

  3. 3. What does print() do?

4. Example — edit and run

python

Output

Press Run to see output.

Expected output: Hello, Ava