Page 358 - Computer Science Class 11 With Functions
P. 358

Solved Exercise


        A.  Multiple Choice Questions
           1.  Which of the following is a mutable data type?
              a.  string               b. integer             c. list                d. tuple

           2.  Consider the following list:
              lst = [1,  5,  0,  15,  30,  50]
              What will be the output produced on 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]
           3.  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)
           4.  Which of the following statements is not true about  list()function?
              a.  Given string as 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.
           5.  Which of the following functions will transform a list to include elements of another list, passed as argument?
              a.  extend()             b. merge()             c. append()            d. join()
           6.  Consider the tuple tpl defined below:

              tpl = ('abc','efg','hij')
              Which of the following is the correct statement for adding a new element to the tuple tpl?
              a.  tpl + ('lmn')        b. tpl + 'lmn'         c. tpl + ('lmn',)      d. None of these
           7.  Which of the following is NOT true about tuples in Python?
              a.  A tuple may comprise a string as one of its elements.
              b.  A tuple is always defined by enclosing its elements within parentheses.
              c.  The method del works on tuples.
              d.  A tuple may comprise a dictionary as one of its elements.
        B.  State whether the following statements are True or False:
           1.  The function count() counts the number of elements of a list.                            _________
           2.  A tuple is a mutable data type.                                                          _________
           3.  When the function sorted() is applied to a list, it modifies the list.                   _________
           4.  When the function sorted()is applied to a tuple, it modifies the tuple.                  _________
           5.  The expressions a = a + b and a += b are equivalent.                                     _________
           6.   The method pop() returns  the element at index 0 of the list.                           _________
           7.   The method pop() returns  the element at index -1 of the list.                          _________
          8. [].append((1, 2, 3)) yields an error.                                                      _________
           9.  If the variable s refers to the list [1, 2, 3], then s.extend((4, 5, 6)) returns None.   _________

          10. [1, 2, 3, 4] is [1, 2] + [3, 4] yields True.                                              _________





         356   Touchpad Computer Science-XI
   353   354   355   356   357   358   359   360   361   362   363