Page 89 - Modular v1.1 Pyhton
P. 89

DIFFERENCE BETWEEN LIST AND TUPLE


                                         List                                          Tuple
                    A list is a sequence of multiple values in an  A tuple is  a collection of objects which is
                    ordered sequence.                              ordered.

                    List is enclosed in square brackets [].        Tuples are enclosed in parenthesis ( ).
                    Elements of the list can be changed.           Elements of the tuple cannot be changed.

                    List has the variable length.                  Tuple has the fixed length.
                    List is mutable.                               Tuple is immutable.

                    List can hold only homogeneous values.         Tuple can  hold both  homogeneous and
                                                                   heterogeneous values.


                     SOME MORE PROGRAMS

                 Program 11: To print the entire tuple.










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














                 Program 12: To use tuple method count and index.









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

















                                                                                               Tuple in Python    87
   84   85   86   87   88   89   90   91   92   93   94