What is Python Variable

What is Python variable?

A Variables play a very important role in other Programming languages, and Python is no exception. A Variable allows you to store values by assigning it to a name, which can be used to refer to the value later in the program

python variable

Creating Variables

Unlike other programming languages, Python has no command for declaring variables.
A variable is created the moment you first assign a value to it.


>>> x=3   # x is the type of Int
>>> print(x)
>>> print(x+3)
>>> print(x)

The variable can be reassigned as many times as you want, in order to change their value.

In python, the variables don’t have specific types, so you can assign a string to variables, and later assign an integer to the same variables.


>>>x=45.23      # x is the type of Int
>>> print(x)
>>> x="this is string"     # x is the type of String
>>> print (x)
this is string
>>>print(x + "!")
this is string!


>>> x = "awesome"
>>> print("Python is " + x)
Python is awesome
Exit mobile version