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

To use the built-in Python list functions, follow the program as given below.












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












                 OPERATIONS ON A LIST


            There are several operations which can be performed on the list. The following table describes the
            various list operations:


             Operator      Operations                                 Explanation

                  +       Joining lists  To add/concatenate two lists together by using the ‘+’ operator
                                         It multiplies a list by an integer ‘n’ and then creates a new list which repeats
                  *       Repeating lists
                                         the original list ‘n’ times by using the ‘*’ operator

                  :       Slicing lists  To access the list elements within a specific range
                                         To check if the contents of the list are the same or not by using the ‘==’
                 ==       Comparing list
                                         operator
            To perform the operations on the list, follow the program as given below.















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

















                                                                                                #List in Python 131
   128   129   130   131   132   133   134   135   136   137   138