PYTHON CORE · LESSON 02

Variables

Number box · about 10 minutes

Learning with progressRead the summary for free. To save the work, log in to the account.
STEP 1

Give me a name.

The variable is like a box with a sticker. Put a number in it with a sign =.

points = 5
Variable as a signed box
Name.pointsSign =lay downInside.5

✦ Now the name points stores the number 5.

STEP 2

Boxes can count.

To the right of = you can write an example. Python will count first, then put the answer in a box. Write the variable name in print without quotation marks.

points = 1 + 4
print(points)

✦ The screen will have 5, not the word points.

IN-CLASS PRACTICE

Type the code yourself

Type the code from the sample manually. See where it stands = and where it stands +.

coins = 1 + 2
print(coins)
Open the editor for class work
HOMEWORK

Solve it yourself

Add 1 and 1. Save the calculation in the variable a and derive its value.

The answer is hidden. Use similar examples from the lesson notes.

Opening up your homework