Page 225 - Information_Practice_Fliipbook_Class11
P. 225
else:
break
position = int(input("Enter Position : "))
if position == 1:
points = 10
elif position == 2:
points = 5
elif position == 3:
points = 3
else:
points = 0
detailList = [eventName, position, points]
pointsTally[schoolName] = detailList
elif choice == 2:
for school in pointsTally:
print(school, pointsTally[school])
elif choice == 3:
school = input("Enter School Name : ")
if school in pointsTally.keys():
print("Congratulations!! You have scored ", pointsTally[school][2], "points")
else:
print("Sorry .. Your school is not registered")
else:
sys.exit()
response = input('Do you want to continue,Reply Y/y of N/n?')
Assessment
A. Multiple Choice Questions
1. Which of the following creates a dictionary?
a. dict1 = {'a', 1:'b',2:'c',30:'d',100}
b. dict2 = {'a',1:'b',2:'c',30:'d',100}
c. dict3 = {'a':1,'b':2,'c':30,'d':100}
d. dict4 = ['a':1,'b':2,'c':30,'d':100]
2. Which of the following data types cannot be used as keys in a dictionary?
a. Tuple b. String c. Integer d. List
3. The statement d.clear() will ___________________________
a. delete all key-value pairs of the dictionary d
b. delete the dictionary d
c. deletes only last key-value pair of dictionary d
d. result in an error
Python Dictionaries 211

