Page 87 - Information_Practice_Fliipbook_Class11
P. 87

Note that each of the variables num1, and num2 refers to the same object, 50 in the memory.


                                                num 1                      50      1734046084944





                                                num 2



                                         Fig 4.3: num1 and num2 pointing to the same object 50
            Now, consider the following assignment statement:
             >>> num1 = 100
            It associates a new data object with the name num1 as shown below:

             >>> id(num1)
                 1734046275024
             >>> id(num2)
                 1734046084944

                                              num 1                      50        1734046084944





                                              num 2                     100        1734046275024


                                          Fig 4.4: num1 and num2 refer to different data objects

            Now let us examine how a mutable object such as a list may be modified.
             >>> lst1 = [30, 60, 10, 20, 50]
             >>> id(lst1)
                 1933477279552











                                 Fig 4.5: Variable lst1 refers to a list object (object id  1933477279552)

             >>> lst2 = lst1
             >>> id(lst2)
                 1933477279552
            Note that each of lst1 and lst2 refers to the same data object.














                          Fig 4.6: Variables lst1 and lst2 refer to the same list object (object id  1933477279552)



                                                                                        Data Types and Operators  73
   82   83   84   85   86   87   88   89   90   91   92