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
- The JS Developer’s Podcast [EP: 2] Variables and Data Manipulation - October 15, 2024
- YouTube Channels to Learn Coding: Top 9 Picks That Will Make a You Master - October 10, 2024
- The JS Developer’s Podcast [EP: 1] Introduction to JavaScript - September 27, 2024
Pingback: Python Data Types | Python Tutorial #5 - Mr Programmer