Data Handling Part 2
Data Handling Part 2
>>>a=4
>>>type(4)
<class ‘int’>
>>>type(a)
<class ‘int’>
2)The value of an object: It is the data-
item contained in the object. Using print
function we can display the value of an
object.
>>>a=4
>>>print(4)
4
>>>print(a)
4
3) The id of an object: The id of an object is
generally the memory location of the object.
id() function returns the id of the object.
>>>id(4)
30899132
>>>a=4
>>>id(a)
30899132
Sample code 308991
>>>id(4) 32
30899132
a 4
>>>a=4
>>>id(a)
30899132
308991
>>>b=5
20
>>>id(5) b 5
30899120
>>>id(b)
30899120 Note - While storing complex numbers id’s
are created differently, So Complex literal
>>>b=b-1
2.4j and complex variable say x having
>>>id(b) value 2.4j may have different id’s
30899132
Example 1
What is the output of the following code?
nset1={11,12,13,13}
print (nset1)
Output {11,12,13}
Example 2
How are following two variables created using { }
different from one another?
V1={11,12,13,14}, V2={11:12,13:14}
Answer V1 is a set and V2 is a dictionary as it contains
key:value pairs.
>>>type(V1)
<class ‘set’>
>>>type(V2)
<class ‘dict’>