Python variable's
Output
5
hallo
hallo
Example
x=5
y="hallo world"
#python understand variable datatype
print(type(x))
print(type(y))
Try it Yourself »
y="hallo world"
#python understand variable datatype
print(type(x))
print(type(y))
Try it Yourself »
Output
Int
string
string
Variable Names
- variable name can't use symbols except underscore(_).
- variable cannot start with a number
- variable must start with alphabet or underscore(_).
- can't use reserve word(keywords)
Example
variable="hallo world"
_myvariable="hallo world"
variable2="hallo world"
Variable="hallo world"
_myvariable="hallo world"
variable2="hallo world"
Variable="hallo world"
Try it Yourself »
Example
@variable="hallo world"
4myvariable="hallo world"
variable 2="hallo world"
~Variable="hallo world"
4myvariable="hallo world"
variable 2="hallo world"
~Variable="hallo world"
Try it Yourself »
addign multipal values
Output
hallo
hi
who are you
hi
who are you
one value for multiple variables
Output
hallo
hallo
hallo
hallo
hallo
Global Variables
Global Function
def myfunc():
global x
x="this is global variable"
myfunc()
print(x)
global x
x="this is global variable"
myfunc()
print(x)
Try it Yourself »
Output
this is global variable
No comments:
Post a Comment
Tell us how you like it.