What are Variables?
Variables are also called as identifiers which is a container used to store the values.
As we discussed earlier that python is not a static typed but a dynamic typed language. so we don't need to assign the type of a variable while creating it. we can create a variable which holds the string value similar to we declare the above variable which holds the integer value.
Python variable or identifier could be anything like you can even have your name as a variable.
As you can see we could even have our name also as a variable but there are certain rules we should be abide by while creating a variable names.
Variables Declaration Rules
-
Variables can contain only alphabets, numbers and underscore.
-
Special Characters are not allowed
-
Variables must start with a underscore or alphabets.
-
Variables can't start with a number.
-
Variables can't be a Reserved Keyword.
-
Variables are case sensitive.
-
Variables can't have space in between.
As variables can't have space in between so to create a multi word variable we could use underscore in between or toggle with uppercase and lowercase to improve the readability.
Variables Multiple Assignment
In python, we can assign multiple variables a single value or multiple variables can be assign multiple values in a single line.
Variables Addition
Try adding to variables:
-
integer to integer
-
String to String
-
Integer to String
Variables Modification
Try changing the values of a variables.
Variables Deletion
When you are done with the use of a variable. you can even delete it using the del keyword.