i

Python Programming

Python Variables

Variables are containers for storing data values. A variable is created the moment you first assign a value to it. You need not to assign int, string or character Python automatically recognizes variables that is the beauty of python as compared to Java. Write below code in IDLE and see output 5 will print as int.

x = 5

print(x)

variables do not need to declare and it automatically declares as shown above. The output of the above is 5.

Another example is

x = “hello python”

print(x)

print(x) will print hello python. Python automatically declares string or integer.

Global Variables is variable created outside of a function or any class like shown below. Write below code in IDLE and run it.

Output would be:

Python is abc         # + operator to separate value