Page 155 - Computer Science Class 11 With Functions
P. 155
Each of the variables lst1 and lst2 refers to the same modified list object.
Fig 7.7: Variables lst1 and lst2 refer to the same list object (object id 1933477279552)
Finally, examine the following:
>>> lst1 = [3, 4, 2, 1]
>>> id(lst1)
2353324714816
>>> id(lst2)
1933477279552
Note that assigning the variable lst1 to a new list object (indeed, it could as well be an object of some other type)
changes its object id. As expected, the assignment of the list object [3, 4, 2, 1] to the variable lst1, did not impact
the variable lst2, which continues to refer to the list [30, 60, 10, 20, 100] (object id 1933477279552).
Fig 7.8: The variables list1 and list2 refer to different objects
Python Datatypes
Immutable Datatypes Mutable Datatypes
Numbers Tuples Lists Sets
Strings Dictionary
Fig 7.9: Mutable and immutable data types in Python
7.3 Visualizing Execution of Python Code
To visualize the execution of Python code, online tool PythonTutor may be used through following link
http://www.pythontutor.com/visualize.html#mode=display
Data Types and Operators 153

