Python Variables:
Variables are containers or memory pool for storing data values.
A variable is created when we assign a value to it.
Example 1:
x = 6 # x is of type int
x = "MANY" # x is now of type str
Example 2:
x = "pop"
# both are same
x = 'pop'
Rules for Variables:
- A variable name must start only with a letter or the underscore character.
- A variable name cannot start with a number.
- A variable name can only contain alpha-numeric characters and underscores (A-Z, a-z, 0-9, and _ ).
- Variable names are case-sensitive (pop, Pop and POP are three different variables)
Note : Python allow to assign value to multiple variable in one line.
Example:
x, y, z = "Car", "Lemon", "Cherry"
Note:Python also allow to assign the same value to multiple variable in one line.
Example:
x = y = z = "Apple"
0 Comments