Lesson 2: Variables and questions
By the end you can: Store information in variables and ask the user questions with input().
1Recall
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
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?
