XII Python Revision tour-II
XII Python Revision tour-II
XII Python Revision tour-II
id():- returns the address of those values. If you are supposed to change the value, address will also changed
a=10
print(id(a))
print(a)
a=20
print(b)
print(id(b))
Variable:
A variable is a label for a location in memory. It can be used to hold a value.
In statically typed languages, variables have predetermined types, and a variable can only
be used to hold values of that type. In Python, we may reuse the same variable to store
values of any type.
Defining variables
To define a new variable in Python, we simply assign a value to a label. For example, this
is how we create a variable called COUNT, which contains an integer value of zero
count = 0
LValues : These are the objects to which you can assign a value or expression. LValues can come on
lhs or rhs of an assignment statement.
RValues : These are the literals and expressions that are assigned to LValues.
e.g. a = 20
b = 10
a and b are LValues , whereas 20 and 10 are RValues.
MULTIPLE ASSIGMENT
1. Assigning same value to multiple variables
You can assign same value to multiple variables in a single statement, e.g.
a = b = c = 10
It will assign value 10 to all three variables a, b, c.