Page 226 - Information_Practice_Fliipbook_Class11
P. 226

4.  What will be the output produced on the execution of the following code snippet?
                  dictItems = {'Mug':400, 'Book':550, 'Watch':950}
                  print(sorted(dictItems))
              a.  ['Book', 'Mug', 'Watch']
              b.  {'Book': 550, 'Mug': 400, 'Watch': 950}
              c.  {'Mug': 400, 'Book': 550, 'Watch': 950}
              d.  None of the above
           5.  Which of the following can be the possible output produced on the execution of the following code snippet?
                 colours = {"red", "green", "blue", "Yellow"}
                  code = 0
                 cDict = {}
                 print( cDict.fromkeys(colours, code) )
              a.  {'Yellow': '0', 'red': '1', 'blue': '2', 'green': '3'}
              b.  {'Yellow': 0, 'red': 0, 'blue': 0, 'green': 0}
              c.  {'Yellow': 1, 'red': 2, 'blue': 3, 'green': 4}
              d.  Error
           6.  Consider the following dictionary:
              subjects = {101:'English', 102:'Hindi', 103:'Maths'}
              Which of the following pairs of expressions will yield the same output?
              a.  subjects.get('102') and subjects[102]
              b.  subjects.popItem(102) and subjects[102]
              c.  subjects.values() and subjects.items()
              d.  subjects[102] and subjects.get(102)
           7.  Which of the given statements will add a new key value pair to the dictionary d1 given below:
                  d1 = {"Netflix":300,  "Prime":250, "Sony Liv": 100}
              a.  d1["Prime"]=190
              b.  d1["Disney Hotstar"]=175
              c.  abc=d1.get("Netflix")
              d.  d1.update({"Sony Liv":280})
           8.  Consider  the following dictionary:
              ticketPrice = {'Chandigarh':450,  'Nagpur':760,  'Pune':380}
              What will be the output of the statement, min(ticketPrice)?
              a.  450                  b. Chandigarh          c. Pune                d. 380

           9.  What will be the output produced on executing the following code segment?
              d = {1:'a', 2:'b', 3:'c'}
              sum(d)
              a.  Error, as aggregate functions do not apply on dictionary
              b.  6.0
              c.  abc
              d.  6

          10.  Which of the following functions will add a key to a dictionary only if it does not already exist in the dictionary?
              a.  update()             b. get()               c. setdefault()        d. fromkeys()
          11.  Which  of  the  following  can  be  used  to  add  to  dictionary,  all  key-value  pairs  of  another  dictionary  in  an  existing
              dictionary?
              a.  update()             b. get()               c. setdefault()        d. fromkeys()

          212  Touchpad Informatics Practices-XI
   221   222   223   224   225   226   227   228   229   230   231