Python Tutorials, Tricks & Tips, Projects, etc..,

Python Variables | Declaring Variables In Python

| July 13, 2018 | TAG: python | No comments:

In this tutorial, you are going to learn about the Python Variables. Variables are the basic part of any programming Language.

Python Variables

Variables are the names used to refer to memory locations. Variables are also known as Identifiers. Variables are used to hold a Value.

python variables

Variables names can be letters or the combination of digits and letters. But, their name must start with a letter or underscore.

Declaring and Assigning Values to Variables

In Python, you need not declare the type of variable while assigning a value to it. Python explicitly takes the value type.

Python Variable value can be a digit, a character, a string or anything that is supported by the Python programming language.

The equal sign (=) is used to assign a value to variables. See the examples.....

>>> variable_name = 5
>>> my_variable = 'h'
>>> my_name = 'geeksbro'

In the above code we declare different variables and assign them different type of data like int, char, string.

Multiple Assignment

#1. Assigning Single Value to Multiple Variables

In this type of statements, you can assign a Single value to Multiple variables.


a = b = c = 7
print(a, b, c)



#2. Assigning Multiple Values to Multiple Variables

In this type of statements, you can assign Multiple values to Multiple Variables.


a, b, c = 1, 2, 3
print(a, b, c)


1 2 3


If you have any Doubts Comment below or Contact us at GeeksBro Facebook Page.

Post a Comment