Page 1 - demo_vp
P. 1

LIST AND TUPLE METHODS


               L=[13,45,67,78,89,123]

               Sr    method      Example with list      Working                              Is same method
               no                                                                            applicable on
                                                                                             tuple
               1     index()     L.index(67)            Returns index of first matched       Yes
                                                        element
               2     append()    L.append(565)          Add a a single element at end        no
               3     extend()    L.extend(L1)           Multiple elements are added given in   no
                                                        form of list
               4     insert()    L.insert(<pos>,element)  Inserts element at given position   no
               5     pop()       L.pop(<index>)         If no index is specified ,last element is   no
                                                        removed
               6     remove()    L.remove(<value>)      Removes the first occurrence of      no
                                                        element
               7     clear()     L.clear()              Removes all elements from list and   no
                                                        returns empty list
               8     count()     L.count(<element>)     Counts occurrence of element         Yes
               9     reverse()   L.reverse()            In place reversal of list            No
               10    Sort()      L.sort()               In place sorting                     No
               11    len()       L.len()                Finds length o fa list               Yes
               12    max()       max(<List>)            Finds element of maximum value       Yes
               13    min()       min(<list>)            Finds element of minimum value       Yes





                                       LESSON 3 :FUNCTIONS IN PYTHON


               Need of functions: For large programs it is very difficult and cumbersomefor a

               programmer to keep track of data and control statements . Therefore to divide large programs
               into different smaller modules ,we define functions. These functions work on given small data
               ,process it ,and return result.

               It is systematic way of problem solving . divide the problem into smaller parts , write a function
               for it, and then integrate all the functions .

               Functions can be categorized into following 3 types







               1
   1   2   3   4