Module 02 • Foundation
Variables& Data
ManoBot now understands instructions. But to travel through ManoCity, she also needs to remember information such as her destination and speed.
Watch
Mano needs to remember.
Watch how Python can store information such as Mano's destination and speed. Then try it yourself below.
The Big Idea
Think of a variablelike a labelled box.
The variable's name is the label. The information we store is the value inside the box.
destination
String — text data
speed
Integer — whole number
Try It
Give Manoa mission.
Choose Mano's destination and speed. Then run the program and watch Python store the information.
Python Memory
Watch the values get stored.
destination
String
speed
Integer
Ready?
Press Run Code to see how Python stores Mano's information.
Different Kinds of Data
Variables can rememberdifferent kinds of information.
destination = "School"
Strings store text. Text is normally placed inside quotation marks.
speed = 3
Integers store whole numbers such as 1, 3, 10 or 100.
distance = 2.5
Floats store numbers containing a decimal point.
One More Idea
Let the userprovide the information.
Instead of putting a value directly into our program, Python can ask the user for information using input().
Remember This
A variable gives informationa name so Python can remember it.
String
"School"
Integer
3
Float
2.5