Learn about Python Variables

Introduction

Variables are used to store different types of values. In Python, you don't have to specify the type of a variable when declaring it. This is the biggest advantage of Python. Whatever data type you store, the variable will automatically become that data type.

Types of python variables

string, int, float, list, tuple, dict, etc. You can find the type of a variable by using the type() method. See the example below.


# String Variable
name = "It's me Rakshit"
# Integer variable
age = 5
print(type(name))
print(type(age))

Output

<class 'str'>
<class 'int'>

Assign a Single Value to Multiple Variables


# Assign a single value to multiple variables
a=b=c=5
print("Sum = ", a+b+c)

Output

Sum =  15

Subhankar Rakshit

Meet Subhankar Rakshit, a Computer Science postgraduate (M.Sc.) and the creator of PySeek. Subhankar is a programmer, specializes in Python language. With a several years of experience under his belt, he has developed a deep understanding of software development. He enjoys writing blogs on various topics related to Computer Science, Python Programming, and Software Development.

Post a Comment (0)
Previous Post Next Post