Skip to content
Home » Blogs » Variables In Python | Python Tutorial #4

Variables In Python | Python Tutorial #41 min read

Variables In Python

Hey Programmers, In this Tutorial We will be Learning About Python Variables so We will be Learn What are Variables, How to Assign Values to a Variable And More.

Also Read: Python Data Types | Python Tutorial #5

Python Variables

Variables In Python are Used to Store Data In a memory. Or In Simple Words Variables are the Containers to Store Holds the Assigned Value Given By the User. Examples:

ADVERTISEMENT

num = 20

In the Above Mentioned Example We Have Created a Variable named num which holds a value of 20, it means When we will print the value of num variable we will get the output 20.

num = 20
print(num)

Output:

20

Changing the Value of a Variable

As we Saw In the Above Examples that we have assigned a value of 20 to a variable called num, And If your Mind Changes you want to change the from 20 to Let’s Say 100, So we can do this By Changing the Value Of the Variable.

num = 100
print(num)

Now, it will print the value of num as 100, Because We Have Changed the Assigned Value of the Variable.

Assigning Values to Variables

In the Above Programs, We change the Values of the Variables, Now we will Assign Values to a Variable, Examples

mr programmer = "mrprogrammer.in"
# I Have Added the Link Of My Website in a Variable 
print(mr programmer)

Output:

mrprogrammer.in

Assigning Multiple Values to Variable

Now, we will See how to Assign Multiple Values In a Single Variable, let’s Say we have three variables fruits

fruits= ['apple','banana',cherry]
print(fruits)

Output:

apple banana cherry
Tanmay Sinha

PROMOTED

The Ultimate Managed Hosting Platform

1 thought on “Variables In Python | Python Tutorial #41 min read

  1. Pingback: Python Data Types | Python Tutorial #5 - Mr Programmer

Leave a Reply