Variables are containers used for storing information.
Creating Variables
Remember that Python variable names are case-sensitive!.
Rules for creating Python variables:
- A variable name must start 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, 0-9, and _ )
- Variable names are case-sensitive (age, Age and AGE are three different variables)
Note: Unlike other programming languages, Python do not need to be declared with any particular type, and can even change type after they have been set. A variable is created the moment when you assign a value to it ie Creating and Declaring are done at a same time.
still if you want to declare then this can be done with casting.
Casting
If you want to specify the data type of a variable, this can be done with casting.
Example
a = str(5) # a will be '5'
b = int(5) # b will be 5
c = float(5) # c will be 5.0