python · level 1 · unit 2 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
A is a box with a name on it.
You put something in the box, write a name on the label, and from then on you say the name to get it back.
Whatever is inside the box is called its . Here the box is called name, and its value is the string "Sam".
To get the value back, use the name with no quotes, like print(name). Spell it the same way every time, or Python gives you a NameError.
name = "Sam" Read the = as “put into”, not “equals”.
guess first
What will this show?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
name = "Sam"
print(name)
your turn
Your turn. Put your name in the box.
Type your name between the quotes, then press run. The + sticks "Hello, " and your name together, and you will learn more about it next lesson.
fix it
This one is broken. Can you fix it?
- Look at the word inside print( ). Is it spelled the same as the box on line 1?
- Two letters are swapped. The box is called name.
- Change nmae to name, then press run.
nailed it
you made the computer remember. :D
- A variable is a box with a name on it.
=puts a value into the box.- Spell the name the same way every time.
new words in your collection
- variable
- value
This lesson isn’t saved. A free account remembers every lesson you finish.