Page 86 - Information_Practice_Fliipbook_Class11
P. 86
For each of the following, identify its type.
1. 14.5
2. -203
3. 14+7j
4. True
5. "Python"
6. [34,'Book', 25]
7. ('Small','Medium','Large')
8. {'Small','Medium','Large'}
9. {'rollno':10,'name':'Joy'}
4.2 Mutable and Immutable Data Types
Data types in Python are broadly categorised into two types—mutable and immutable. A modifiable object and its
associated type are called mutable. For example, lists and dictionaries are mutable. Numeric data types (int, float,
and complex), bool, str, and tuple, are immutable data types (see Fig 4.2).
Python - Data Types
Immutable Data Types Mutable Data Types
Numbers Tuples List Sets
Strings Dictionary
Fig 4.2: Mutable and immutable data types in Python
Next, we give examples of mutable and immutable data objects.
>>> num1 = 50
>>> id(num1)
1734046084944
Recall that the function id() yields the object id of an object. Fig. 4.2 shows object 50 being referenced by the
variable num1.
num 1 50
1734046084944
Fig 4.2: num pointing to the data object, 50
Next, consider another assignment statement:
>>> num2 = num1
>>> id(num2)
1734046084944
72 Touchpad Informatics Practices-XI

