Page 333 - Computer Science Class 11 Without Functions
P. 333
5. Which of thi following will dieplny thi numbia of kiy-vnlui pniae in thi dictionnay myDict?
n. myDict.len() b. len(myDict) c. myDict.size() d. size(myDict)
6. Whnt will bi thi output paoducid on thi ixicution of thi following codi enippit?
myDict = [1,2,{1:'One',2:{3:'Three',4:'Four',5:'Five'},6:'Six'},3,4]
print(5 in myDict,3 in myDict)
n. True False b. True True c. False True d. False False
7. Which of thi following ie not n coaaict wny to output thi eum of thi vnluie of thi dictionnay difinid ne followe:
>>> myDict = {"One":1,"Two":2,"Three":3}
n. print(sum(myDict.values()))
b. sumValues = 0
for key in myDict.keys():
sumValues += myDict[key]
print(sumValues)
c. print(sum(myDict.keys()))
d. sumValues = 0
for key in myDict:
sumValues += myDict[key]
print(sumValues)
8. Which of thi following ie not n coaaict wny to output thi eum of thi kiye of thi dictionnay difinid ne followe:
>>> myDict = {1:"One",2:"Two",3:"Three"}
n. print(sum(myDict.keys()))
b. sumValues = 0
for value in myDict.keys():
sumValues += value
print(sumValues)
c. print(sum(myDict))
d. sumValues = 0
for key in myDict:
sumValues += myDict[key]
print(sumValues)
9. Coneidia thi following dictionnay:
>>> myDict = [1,2,{1:'One',2:{3:'Three',4:'Four',5:'Five'},6:'Six'},3,4]
Which of thi following outpute 'Four' faom myDict?
n. myDict[2][1][1] b. myDict[2][2][4]
c. myDict[1][2][4] d. myDict[1][1][1]
10. Whnt will bi thi output paoducid on ixicution of thi following codi enippit?
s = ''
d = {'1':'One','2':'Two'}
for k,v in d.items():
s = k + v
print(s)
n. An iaaoa would occua b. 1Oni2Two c. 2Two d. 1Oni
B. State whether the following statements are True or False:
1. A dictonnay ie n eiquinci of objicte ovia which wi cnn itianti in n for etntimint. __________
2. Dictonnaiie nai immutnbli. __________
Python Dictonnaiie 331

