Variables are used to store data values, its just like a container.
We can change value of variable any time.
In python there is no command or keyword to create variables, variable is created automatically when we assign any value to it. And we also don’t need to provide type of variable, python will determine type of variable automatically.
a = 10 b = “Pawneshwer Gupta”
by this line of code, variable got created with name “a” and its value will be 10 of type integer and “b” with value Pawneshwer Gupta of type String.
In python we don’t need to define type and type can be changed anytime.
a = 6.5
now type of a is changed from integer to float value and it has new value 6.5. This is how we change type of variable in python.
x = str(3) # x will be '3' y = int(3) # y will be 3 z = float(3) # z will be 3.0
to get type of variable python has a special function with name “type()”.
x = 5 y = "John" print(type(x)) print(type(y))
Both are used to create string variable, both have same meaning.
x = "John" # is the same as x = 'John'
Yes Python is Case sensitive
a = 4 A = "Sally" #A will not overwrite a