Input, print and numbers - Learn Python 3 - Snakify

Lesson 1. Input, print and numbers




16/24. Variables

When writing a complex program, you usually can't print the answer of your calculation right away. Instead you use variables to store intermediate results.

Look at the code section. The first line has three parts: a = 3

To the left of the assignment operator* we put a name of variable, in this case, a. The name can be any string of latin characters mixed with numbers and the underscore _ but cannot start with a number. So, much3q1 is a valid name for a variable, and 2pac is not.

To the right of the assignment operator* we put any expression that Python can evaluate. It can be 3 as in the code below, or it can be, say, 1 + (2 ** 8) % 5.

*The assignment operator is =.

Look what we've done: we assigned to the variable a the value of 3. We can read this as "a is assigned the value of 3" or "a gets 3". All right, now.

Instructions


a = 3
print(a)