2.0.3 - Assign a value (not a mission) to a variable

Variables are specific locations in computer's memory. We need to use them because we live in a rapid changing environment and we need to remember past values of anything we want to describe. Time, temperature, light are some of these changing concepts.

Variables in Python are named by us and a smart tactic is to name a variable according to what they represent.
So light could be the name of the variable that we use to measure the light intensity of a room.
Be careful that names are case sensitive, so Light is a different variable than light.

We can not use reserved characters,  space connected words or numbered started words as variable names.

Every variable belongs to a type, so we have string(text) variables, integer variables, floating point variables and others.

Python variables do not need explicit declaration to reserve memory space. The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.

The operand to the left of the = operator is the name of the variable and the operand to the right of the = operator is the value stored in the variable.

counter = 100          # An integer assignment
miles   = 1000.543     # A floating point
name    = "John"       # A string

type() function returns the type of a variable. For example:


>>> type(counter)
<class 'int'>


Python allows you to assign a single value to several variables simultaneously.

>>> a = b = c = 1