24. Write a Python program to input 'n' classes and names of their class teachers to store them in a dictionary
and display the same. Also accept a particular class from the user and display the name of the class
teacher of that class.
Answers
Answered by
15
Answer:
schooldict ={}
no_of_class=int(input('Enter the number of classes:'))
for x in range(1,no_of_class+1):
schooldict[x] = input('Enter the teacher names:')
print("Display:")
print(schooldict)
classId=int(input('Enter class Id:'))
if classId in schooldict:
print ("teacher name: " + str(schooldict[classId]) + "\n")
Explanation:
Similar questions