PYTHON-VARIABLE

Variables are containers for storing data values.

Python has no command for declaring a variable.

Variable name cannot start with number.

Variable name can only contain alpha numeric char and underscores (A-Z, 0-9, and _).

Variable name is case sensitive (name, Name and NAME are three different variables).

Example for Valid Variables

name= "Ram"

User_name= "Ram"

name2= "Ram"

How to find a data type in python

We can use type()

a = 20

b = 20

c = a + b

print(type(c))

Output: <class 'int'>

How to know variable memory location in python

We can use the id()

a = 20

b = 20

c = a + b

print(id(c))

Output 140715156367368

Based on variable value it will allocate the memory location

Ex:

a = 20

b = 20

c = a + b

print(id(a))

print(id(b))

Output

140715156366728

140715156366728

Here same memory location allocated because variable a and b is same value.