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

Assessment


            A.  Multiple Choice questions
               1.  Consider the following statements:
                     data1 = (3, 10, 5, 'good', 12.3)
                    data2 = [3, 10,5, 'good', 12.3]
                  Which of the following statements is correct?
                  a.  Both data1 and data2 are immutable
                  b.  data1 is mutable and data2 is immutable
                  c.  Both data1 and data2  are mutable
                  d.  data1 is immutable and data2 is mutable

               2.  Which of the following statements will create an empty list?
                  a.  lst = ()
                  b.  lst = list()
                  c.  lst = empty()
                  d.  lst = null_list()
               3.  What will be the output produced on execution of the following code:
                  message = "Never give up"
                  myList = message.split('e')
                  print(myList[-2], myList[2])
                  a.  give up
                  b.  v r giv
                  c.  r giv r giv
                  d.  r giv  up
               4.  Which of the given statements will result in an error?
                  lst = [1,2,3,4]             # Statement 1
                  tup = (1,2,3,4)             # Statement 2
                  print(tup[0])               # Statement 3
                  sorted(tup)                 # Statement 4
                  tup[1] = lst                # Statement 5
                  lst[1] = tup                # Statement 6
                  a.  Statement 3          b. Statement 4         c. Statement 5        d. Statement 6
               5.  If lst = [None], what will be the result  produced on evaluating the  following expression, lst*3?
                  a.  []
                  b.  [[None], [None], [None]]
                  c.  [None, None, None]
                  d.  None
               6.  Consider  the  following  statements  and  select  the  correct  output  that  will  be  produced  when  they  are  executed  in  a
                  sequence:
                  numbers = [3, 10, 5, 15, 20, 34, 8, 5]
                  numbers[4:8:2] * 2
                  a.  [20,  8]
                  b.  [20,  8,  20,  8]
                  c.  Error
                  d.  []


                                                                                                Lists and Tuples  363
   360   361   362   363   364   365   366   367   368   369   370