Q. Write a program to store student names and their percentage in a dictionary and delete a particular student name from the dictionary. Also display the dictionary after deletion.


Answer = 

 

dic = {}

while True :
    nam = input("Enter name :- ")
    per = float(input("Enter percentage :- "))
    dic[nam] = per
    a = input("Do you want to enter more records enter (Yes/ No) :- ")
    print()
    if a == "No" or a == "no":
        break
    

clas = input("Enter name which you want to delete :- ")
del dic[clas]
print("Dictionary",dic)

Output :-

Enter name :- Path
Enter percentage :- 99.4
Do you want to enter more records enter (Yes/ No) :- yes

Enter name :- Walla
Enter percentage :- 85.2
Do you want to enter more records enter (Yes/ No) :- yes

Enter name :- Portal
Enter percentage :- 76.92
Do you want to enter more records enter (Yes/ No) :- No

Enter name which you want to delete :- Walla
Dictionary {'Path': 99.4, 'Portal': 76.92}

>>>



14 Comments

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

  1. name 'true' is not defined.

    ReplyDelete
    Replies
    1. Please enter correct spelling. It is "True" not "true".

      Delete
  2. Instead of clas name will come.

    ReplyDelete
    Replies
    1. I did not understand what you want to please comment again.

      Delete
  3. I wrote this in my exam but my teacher told me that it is wrong ....is my teacher right???

    ReplyDelete
    Replies
    1. Don't worry she is wrong. You can run the program in front of your teacher and get the marks.

      Delete
  4. Replies
    1. I didn't understand what you want to say please tell me again.

      Delete
  5. Display the output

    ReplyDelete
  6. can you explain using for loop........

    ReplyDelete
    Replies
    1. we can not use for loop for infinite times.

      Delete
  7. do u have youtube channel in which u can explain in video?

    ReplyDelete

Post a Comment

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

Previous Post Next Post