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

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 the 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. []
               7.  Consider the following list:
                      names = ['jaipur', 'nagpur', 'pune', 'shimla']
                  Which of the following statements will insert the string, 'agra' as the third element of the list?
                  a.  names.insert(2, 'agra')
                  b.  names.insert(3, 'agra')
                  c.  names.extend(2, 'agra')
                  d.  names.extend(3, 'agra')
               8.  Consider the following list:
                      names = ['jaipur','nagpur', 'pune', 'shimla']
                  Which of the following statements will delete the string 'pune' from the list?
                  a.  names.pop()
                  b.  names.pop(3)
                  c.  names.remove('pune')
                  d.  names.remove(2)
               9.  What will be the output produced if the following code is executed?
                  tup = (1, 2, 3, 4, 5)
                  mySum = sum(tup, 10)
                  print(mysum)
                  a.  15                   b. 25                  c. Error              d. No output


                                                                                                Lists and Tuples  315
   312   313   314   315   316   317   318   319   320   321   322