Page 310 - Computer Science Class 11 Without Functions
P. 310

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 the 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 the above
           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.                                                     ________




         308   Touchpad Computer Science-XI
   305   306   307   308   309   310   311   312   313   314   315