Page 85 - tp_Modula_v2.0
P. 85

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

                     Output

                  After append and extend: [13, 25, 41, 63, 82, 19, 26, 43, 55]
                  After insert: [13, 302, 25, 41, 63, 82, 19, 26, 43, 55]
                  After remove: [13, 302, 25, 41, 82, 19, 26, 43, 55]
                  Index of 13: 0
                  Count of 41: 1
                  After reverse: [55, 43, 26, 19, 82, 41, 25, 302, 13]
                  After pop (removed 26): [55, 43, 19, 82, 41, 25, 302, 13]
                  Copy of the list: [55, 43, 19, 82, 41, 25, 302, 13]
                  After sort: [13, 19, 25, 41, 43, 55, 82, 302]
                  After clear: []



                  Clickipedia



                   The ‘+’ operator when used with lists needs both the operands to be of list type, otherwise
                   it will produce an error.

                     PYTHON FUNCTIONS

                 Python also provides various built-in Python list functions. The following table describes various
                 Python built-in functions.

                                    Function                                Explanation

                          len(list)                      Returns the total length of the list
                          max(list)                      Returns the largest element from the given list

                          min(list)                      Returns the smallest element from the given list


                 Program 7: Python built-in functions.
                     Program7.py
                  File  Edit  Format  Run   Options   Window    Help
                  list = [13, 25, 41, 63, 82, 19, 26, 43, 55]
                  print("Length of the list:", len(list))
                  print("Largest element the list:", max(list))
                  print("Smallest element in the list:", min(list))



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

                     Output

                  Length of the list: 9
                  Largest element in the list: 82
                  Smallest element in the list: 13





                                                                                                 List in Python   83
   80   81   82   83   84   85   86   87   88   89   90