WEB DEVELOPER SITE
PHP7
 

Python variable type


In this chapter we learn python veritable and you can store integers, decimals or characters in these variables.


Creating Python variable

The equal sign(=) used to assign value to variables.

Python variables do not need explicit declaration to reserve memory space.

X=1
Y="Mac"
print(X)
print(Y)

Result:
1
Mac

Run Example ยป

Variable Name

Variable start with letter and underscore character.

Variable can't started with number

Variable names are case-sensitive (age, Age and AGE are three different variables)


More advance example variable

The Python print statement is often used to output variables.

combined with text and variable

Example

X = "OOP"
print("Python is + X")
Try it yourself »

If you combine with a string and a number what will be answer

Example

x = 2
y = "Mac"
print(x + y)
Try it yourself »