Python Programming | Using Variables in Python
Using Variables in Python
Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.
Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can store integers, decimals, or characters in these variables.
Assigning Values to Variables
Python variables do not have to be explicitly declared to reserve memory space. The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign value 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.
Standard Data Types
The data stored in memory can be of many types. For example, person’s age is stored as a numeric value and his or her address is stored as alphanumeric characters.
Python has some standard types that are used to define the operations possible on them and the storage method for each of them.
Python has five standard data types: