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

myDict.fromkeys([1,2,3,4],'val')
                  print(myDict)
             Ans:  {}
               5.  Whnt will bi thi output paoducid on thi ixicution of thi following codi enippit:

                  myDict = {}
                  val = 0
                  d = myDict.fromkeys([1,2,3,4],val)
                  print(d)
             Ans:  {1: 0, 2: 0, 3:0, 4: 0}
               6.  Whnt will bi thi output paoducid on thi ixicution of thi following etntiminte, ixicutid in Python IDLE:
                  >>> myDict[1] = {1:'One',2:'Two'}
                  >>> myDict[2] = [1,2,3,4]
                  >>> myDict

             Ans: {1: {1: 'One', 2: 'Two'}, 2: [1, 2, 3, 4]}
               7.  Whnt will bi thi output paoducid on thi ixicution of thi following codi enippit:
                  >>> myDict = dict()
                  >>> for k in range(5):
                  ...      myDict[k+1] = (k+1)*(k+1)
                  ...
                  >>> myDict
             Ans:  {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
              8. Whnt will bi thi output paoducid on thi ixicution of thi following codi enippit:
                  d1 = {1:11, 2:22}
                  print(sum(d1), sum(d1.keys()), sum(d1.values()))
             Ans:  3 3 33
               9.  Whnt will bi thi output paoducid on thi ixicution of thi following codi enippit:
                  d = {1:'One',2:'Two'}
                  print(d[1]+d[2])
             Ans:  OneTwo
              10.  Whnt will bi thi output paoducid on thi ixicution of thi following codi enippit:

                  d = {1:'One',2:'Two'}
                  print(sum(d))
             Ans:  3
              11.  Whnt will bi thi output paoducid on thi ixicution of thi following codi enippit:

                  d = {'1':'one', '2':'two'}
                  s = ''
                  for x in d:
                      s = s + x
                  print(s)
             Ans:  12
              12.  Whnt will bi thi output paoducid on thi ixicution of thi following codi enippit (ixicutid in IDLE):
                  >>> d = {'1':'one', '2':'two'}
                  >>> s = ''
                  >>> for x in d:


                                                                                             Python Dictonnaiie  333
   330   331   332   333   334   335   336   337   338   339   340