ManoCity
LearningPython EssentialsVariables & Data

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.

15 MinutesBeginner1 VideoInteractive Activity

Watch

Mano needs to remember.

Watch how Python can store information such as Mano's destination and speed. Then try it yourself below.

Finished watching? Now see what happens inside Python.

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

"School"

String — text data

speed

3

Integer — whole number

Try It

Give Manoa mission.

Choose Mano's destination and speed. Then run the program and watch Python store the information.

3
mano_mission.py
1destination = "School"
2speed = 3
3
4print("Destination:", destination)
5print("Speed:", speed)

Python Memory

Watch the values get stored.

🧠

destination

Empty

String

speed

Empty

Integer

Ready?

Press Run Code to see how Python stores Mano's information.

Different Kinds of Data

Variables can rememberdifferent kinds of information.

String

destination = "School"

Strings store text. Text is normally placed inside quotation marks.

Integer

speed = 3

Integers store whole numbers such as 1, 3, 10 or 100.

Float

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().

ask_mano.py
destination = input("Where should Mano go? ")
print("Destination:", destination)

Remember This

A variable gives informationa name so Python can remember it.

String

"School"

Integer

3

Float

2.5