Page 200 - Information_Practice_Fliipbook_Class11
P. 200

Ø   extend(lst): inserts the elements in the list lst, passed as an argument, at the end of the elements
              of the list lst.
          Ø   index(elem): returns the index of the first occurrence of the element elem in the list.
          Ø   reverse(): reverses the order of the elements in the list.
          Ø   sort(): arranges the elements of the list in the ascending order.
          Ø   remove(element): searches for the first instance of the element in the list lst and removes it.

          Ø   pop(index): removes the element from the specified  index and returns the element removed from
              the list.





                                               Solved Exercises


        A.  Multiple Choice Questions
           1.  Consider the following list:
              lst = [1,  5,  0,  15,  30,  50]
              What will be the output produced on the execution of the following statement?
              print(lst[1:2]  +  lst[3:6], lst)
              a.  [5, 15, 30, 50][1,  5,  0,  15,  30,  50]
              b.  [5, 15, 30, 50][5, 15, 30, 50]
              c.  [1, 5, 0, 15, 30][1, 5, 0, 15, 30]
              d.  [1, 5, 0, 15, 30][1,  5,  0,  15,  30,  50]
           2.  Which of the following returns the element myList[-1] from the list  myList?
              a.  del myList           b. myList.pop()        c. myList.remove()  d. pop(myList)
           3.  Which of the following statements is not true about list() function?
              a.  Given string as an argument, it returns a new list comprising the elements of the string.
              b.  It can be used to create an empty list.
              c.  It converts a complex number into a list.
              d.  It converts a tuple into a list.

           4.  Which of the following functions will transform a list to include elements of another list, passed as an argument?
              a.  extend()             b. merge()             c. append()            d. join()
        B.  State whether the following statements are True or False:
           1.  The function count()counts the number of elements of a list.                            __________
           2.  When the function sorted() is applied to a list, it modifies the original list.         __________
           3.  The method pop() returns the element at index 0 of the list.                            __________
           4.  The method pop() returns the element at index -1 of the list.                           __________
           5.  [].append((1, 2, 3)) yields an error.                                                   __________
           6.  If the variable s refers to the list [1, 2, 3], then s.extend((4, 5, 6)) returns None.   __________
           7.  [1, 2, 3, 4] is [1, 2] + [3, 4] yields True.                                            __________
        C.  Fill in the blanks.
           1.  The ____________ function is used to add an element at the end of an existing list.
           2.  The list is ____________ data type.
           3.  The method mean() is included in the module ____________.
           4.  The expression [].pop() will yield ____________.

          186  Touchpad Informatics Practices-XI
   195   196   197   198   199   200   201   202   203   204   205