Learn / Python Level 1

Lesson 2: Variables and questions

By the end you can: Store information in variables and ask the user questions with input().

1Recall

Question 1

1. What does print("Hi") do?

Question 2

2. Text inside quotes is called a…

Question 3

3. Why do programmers write comments?

2New idea

A variable is like a labelled box. You give it a name and put something inside. Later you can use the name to get the value back.

pet is the label, "Biscuit" is what's inside.

input() asks the person using your program a question and gives back whatever they type. We usually store the answer in a variable.

  • = means "put this value in the box"
  • Variable names have no spaces: use pet_name, not pet name
  • print() can show several things, separated by commas: print("Hi", name)
  • You can join strings with +: "Hi " + name

3Show me

Type answers in the Answers box (one per line), then press Run.

4Challenge 1

5Challenge 2

6Check

Question 1

1. After colour = "red", what does print(colour) show?

Question 2

2. Which is a good variable name?

Question 3

3. What does input() give back?

7At home

8Reflect

  • Explain a variable to someone at home using a real-life example.
  • What question would you like your next program to ask?
Next: Lesson 3, Numbers and maths →