Hi All,
Today we are going to learn python variables.
a=1 # variable as int b="aravin" # variable as string x=5 # First assign the int value to X x='aravin' # Later assign the str value to X print(x) # o/p aravin, recently assign value to use same variable.
a=100 A='India' # a will not overwrite to A both are diff. print(a) print(A)
var=100 mvar='Hello' print(type(var))
Ex:
Proper Name:
my_variable_name = "Aravin" #snake type
myVariableName = "Aravin" #Camel type
MyVariableName = "Aravin" #Pascal type
myvarname = "Aravin"
_myvarname = "Aravin"
myvar_name = "Aravin"
myvar21 = "Aravin"
Improper Name:
2myVar = "Hello"
my-var = "Hello"
my var = "Hello"
a,b,c = 5,"aravin","DB"
a = b = c = "Apple"
myVar = ["var1","var2","var3"] a,b,c = myVar print(myVar) print(b)
Ex:
a = "python" def myfunc(): print("Hello " + a) myfunc()
a = "python" def myfunc(): a = "python" print("Hai " + a) myfunc() print("Hello " + a)
def myfunc(): global a a = "python" myfunc() print("Hello " + a)
a = "python" def myfunc(): global a a = "Python" myfunc() print("Hai " + x)
The above is the detailed content of Python: Variables. For more information, please follow other related articles on the PHP Chinese website!