Python Variables and Variable names are very important to learn Python. If you want to learn python then you have very deep knowledge about python variables. Today we learn variables in using real life. Python is a very useful coding language. We are makes many things using python.
Variables Coding
ourvariables1 = 5
ourvariables2 = "Character Name"
print(ourvariables1)
print(ourvariables2)
Here we print two variables. Here we show 1st variable that type is an integer. The second variable type is a character type. Integer and character difference the quotation only.
If we use our code in that way,
ourvariables1 = 5
ourvariables1 = "Character's Name"
print(ourvariables1)
Then Its shows the Character's Name only. An integer does not show because python read the coding line by line. Here firstly ourvariables1 is put into an integer in the first line but second-line ourvariables1 is put into the character value. Then it shows the character value.
Second Example
x = str(3)
y = int(3)
z = float(3)
print(x)
print(y)
print(z)
Result:
Here Show 3 Variables like string, integer, and float types. You can easily input anything with this code and the results will be shown as the results photos.
How to show the Types name of Variables
x = 5
y = "John"
print(type(x))
print(type(y))
If this code you run then it shows the variables type name like its integer or character or floats. Here John is a character type and 5 is an integer type. Here output shows below the result. Here integer value and string value are shown like that.
One thing every character quotation is working as a single quotation or double quotation. No issue if we are using a single quotation or double quotation.
How many possible ways to use Variable Names in Python
myvar = "Coder"
my_var = "Coder hasan"
_my_var = "Coder 2"
myVar = "Coder 3"
MYVAR = "Coder 4"
myvar2 = "hasan"
print(myvar)
print(my_var)
print(_my_var)
print(myVar)
print(MYVAR)
print(myvar2)
Here you can use your Variable that way. You can't use 2myvar, my-var, my var this three types of variables in which the first word is a number and then word. It also not using when you use hypen in your word, and you can't use space also in your variables.