Page 98 - tp_Modula_v2.0
P. 98

On running the above program, you will get the following output:

                      Output
                   (1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6)
                   (4, 5, 6, 1, 2, 3)
                   (1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6)




                      CHANGING A TUPLE

                  Elements of a tuple cannot be changed, but, if a tuple contains a list as its member then that
                  member can be change by using the index value of the list element.

                  Program 9: To change a tuple.
                      Program9.py
                   File  Edit  Format   Run   Options  Window    Help
                   tuple=(162, [7, "Orange", 15.5], (2, "Orange Education", 70.5))
                   print[1] [1]="Team"
                   print(tup1e)



                  On running the above program, you will get the following output:
                      Output

                   (162, [7, 'Team', 15.5], (2, 'Orange Education', 70.5))




                      DELETING A TUPLE

                  Elements of a tuple cannot be deleted or removed, but we can delete the entire tuple by using
                  the del keyword.

                  Program 10: To delete a tuple.

                      Program10.py
                   File  Edit  Format   Run   Options  Window    Help

                   tup=(162, [7, "Orange", 15.5], (2, "Orange Education", 70.5))
                   del tup
                   print(tup)



                  On running the above program, you will get the following output:

                  This will cause a NameError because 'tup' no longer exists.

                      Output

                   NameError: name 'tup' is not defined







                   96     Touchpad MODULAR (Version 2.0)
   93   94   95   96   97   98   99   100   101   102   103