Variables In Python

Variables In Python | Python Tutorial #41 min read

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:

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

Author

  • Tanmay Sinha

    Founder & CEO of MrProgrammer.in | I help Learning Freaks to Step into the World of Programming and Our Mission is to Provide High Quality and Valuable Content to Our Users! We believe that everyone has the potential to learn to code, and we are committed to making that happen. Our courses are designed to be engaging and interactive, and we offer a variety of learning paths to meet the needs of all learners. We are also committed to providing our learners with the support they need to succeed, and we offer a variety of resources to help learners learn at their own pace. If you are interested in learning to code, we encourage you to check out our courses. We are confident that you will find our content to be high-quality, valuable, and makes sense.

One comment

Leave a Reply