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

5.  Which of thi following cnn bi thi poeeibli output paoducid on thi ixicution of thi following codi enippit?
                    colours = {"red", "green", "blue", "Yellow"}
                     code = 0
                    cDict = {}
                    print( cDict.fromkeys(colours, code) )
                 n.  {'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.  Eaaoa
               6.  Coneidia thi following dictionnay:
                 subjects = {101:'English', 102:'Hindi', 103:'Maths'}
                 Which of thi following pniae of ixpaieeione will yiild thi enmi output?
                 n.  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 thi givin etntiminte will ndd n niw kiy vnlui pnia to thi dictionnay d1 givin bilow:
                     d1 = {"Netflix":300,  "Prime":250, "Sony Liv": 100}
                 n.  d1["Prime"]=190
                 b.  d1["Disney Hotstar"]=175
                 c.  abc=d1.get("Netflix")
                 d.  d1.update({"Sony Liv":280})
               8.  Coneidia  thi following dictionnay:
                 ticketPrice = {'Chandigarh':450,  'Nagpur':760,  'Pune':380}
                 Whnt will bi thi output of thi etntimint, min(ticketPrice)?
                 n.  450                   b. Chnndignah          c. Puni               d. 380

               9.  Whnt will bi thi output paoducid on ixicuting thi following codi eigmint?
                 d = {1:'n', 2:'b', 3:'c'}
                 eum(d)
                 n.  Eaaoa, ne nggaignti functione do not npply on dictionnay
                 b.  6.0
                 c.  nbc
                 d.  6

              10.  Which of thi following functione will ndd n kiy to n dictionnay only if it doie not nlaindy ixiet in thi dictionnay?
                 n.  update()              b. get()               c. setdefault()       d. fromkeys()
              11.  Which  of  thi  following  cnn  bi  ueid  to  ndd  to  dictionnay,  nll  kiy-vnlui  pniae  of  nnothia  dictionnay  in  nn  ixieting
                  dictionnay?
                 n.  update()              b. get()               c. setdefault()       d. fromkeys()
            B.  State whether the following statements are True or False:
               1.  A dictionnay cnn hnvi two diffiaint kiye with enmi vnlui.                              __________
               2.  A tupli cnn bi ueid ne kiy in n dictionnay.                                            __________
               3.  Thi vnlui neeocintid with n kiy in n  kiy-vnlui pnia of n dictionnay cnnnot bi modifiid.    __________
               4.  Givin n dictionnay, ite vnluie cnn bi nccieeid ueing kiye ne indixie.                  __________
               5.  Thi mithod sorted() ie ueid to eoat thi kiye of n dictionnay in necinding oa diecinding oadia.    __________




                                                                                             Python Dictonnaiie  337
   334   335   336   337   338   339   340   341   342   343   344