Hey!! Dear visitors!! You’re most welcome on bittutech.com. I hope you all are fine. So today, I am going to write an interesting blog post of Python Programming Language to enhance your skills.
Let’s get started–:
Table of Contents
A variable in Python represents named location that refers to a value. we can say that named labels, whose values can be used and processed during running of the program, are called Variables.
The variables are called symbolic variables because these are named labels.
Marks = 50
Here, ‘Marks‘ is a variable which refers a value that is ‘50‘ .
Creating a Variable in Python Programming Language–:
Python variables are created by assigning value of desired type to them, e.g., to create a numeric variable assign a numeric value to variable_name; to create a string variable assign a string value to variable_name and so on.
Programmer = ‘Prajjwal’ } String value
Age = 21 } numeric value
IMPORTANT — Variables are Not Storage Containers in Python
BUT PYTHON VARIABLES ARE NOT CREATED IN THE FORM MOST OTHER PROGRAMMING LANGUAGES DO. Most programming languages create variables as storage containers.
age = 15 age = 20
Firstly value 15 is assigned to variable age and then value 20 is assigned to it.
Lvalues and Rvalues in Python Programming Language–:
Lvalues are the objects to which you can assign a value or expression. Lvalues can come on LHS ( Left Hand Side ) or RHS ( Right Hand Side ) of an assignment statement.
Rvalues are the literals and expressions that are assign to Lvalues. Rvalues can come on RHS of an assignment statement.
In Python, assigning a value to a variable means, variables value is referring to that value.
Multiple Assignment in Python Programming Language–:
There are two different ways by which you can use assignments in Python.
1. Assigning same value to multiple variables.
You can assign same value to multiple variable in a single statement.
a = b = c = 10
It will assign value 10 to all three variables a, b, c
2. Assigning multiple values to multiple variables.
Even, You can assign multiple values to multiple variables in single statement.
x, y, z = 10, 20, 30
It will assign the values order wise.
Last words -:
I hope, you all are very happy and enjoy this blog post. Always, my all efforts only for you to enhance your technical knowledge and bring something new in front of you. Thanks for your love and support as always.