Page 132 - Plus V4 with Adobe class 8
P. 132

Double Tap                                                  Century   #Information Literacy
                                                                               21 st
                                                                               Skills
               Match the methods with their use.

               1. extend( )          a. Removes the first element from the list.

               2. append( )          b. Reverses the order of the elements in the list.
               3. remove( )          c. Adds the element at the end of the existing list.

               4. sort( )            d. Returns the occurrence (number of times) of a particular element in the list.

               5. reverse( )         e. Sorts all the elements in the list.
               6. count( )           f. Adds more than one element to the end of the existing list.




             ADDING AN ELEMENT TO A LIST

        An  element  is  added  to  a  list  by  using  the  append( )  method.  It’s  a  built-in  Python  method.
        If you want to add more than one element to a list, then you can use extend( ) method.

        To add elements to a list, follow the program as given below.














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













             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




            130  Plus (Ver. 4.0)-VIII
   127   128   129   130   131   132   133   134   135   136   137