Python variables
Python

Python variables

Mishel Shaji
Mishel Shaji

In programming, a variable is a value that can be changed. All variables will have a storage location and a name. The variable name is usually used to refer to the value that is stored in a variable.

Declaring variables in Python

In Python, a variable is declared when you set a value to the variable. Unlike some other programming languages, Python does not have special keywords for declaring a variable.

Example

a = 1
b = 1.0
c = 'a'
d = 'Hello World';
print(a)
print(b)
print(c)
print(d)

Output

1
1.0
a
Hello World

You can also create multiple variables in a single line.

a,b = 10,"John"
print(a)
print(b)