Python Variables
Python Variables
The main difference between python variables and other languages is the absence of command for declaring a variable.
- Storage box or container to store value
- Dynamically Typed
- Variable declaration – Not required
- Automatic data type assignment
Rules for variable creation
- You cannot start with a letter or underscore character.
- Cannot start with numeric or integer value.
- May contain letters, numbers or its combination (alpha-numeric characters) and underscore (A-Z, a-z, _, and 0 up to 9).
- Variable names are case-sensitive Eg: name, Name, and NAME are three different variables).
- Reserved words or keywords cannot be used as a variable.
Possible Formats
String/Character, Integer, Floating point values, Boolean.
How Does + Operator Work With Variables?
Assigning Different Values to Multiple Variables
Example 1:
Example 2:
Can We Use the Same Name For Different Types
If We use the same name, the variables start referring to new value and type.
Click Here-> Get Python Interview Questions and Answers