Q. 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.

 

Answer = 

 



dic = {}

while True :
    clas = int(input("Enter class :-"))
    teach = input("Enter class teacher name :-")
    dic[clas]= teach
    a = input("Do you want to enter more records enter (Yes/ No)")
    if a == "No" or a == "no":
        break

clas = int(input("Enter class which you want to search"))
print("class teacher name",dic[clas])

3 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post