Q. Which of the following will result in an error for a given valid dictionary D?
(i)
D + 3
(ii)
D * 3
(iii)
D + {3 : "3"}
(iv)
D.update ({3 : "3"})
(v)
D.update({"3" : 3})
(vi)
D.update("3": 3)
Answer:-
Options (i), (ii), (iii), & (vi)
The explanation for (i):- We can not add the number to the dictionary because the dictionary has keys and value pairs.
Explanation for (ii):- We can not do arithmetic operations on the dictionary directly.
Explanation for (iii):- We can not directly add keys and value pairs. Correct way : D[3] = "3"
Explanation for (vi):- We have to pass the dictionary in the update function.
otha
ReplyDeletelol tamilaa neeega
DeleteI think 5th one also error?
ReplyDeletePlease check it again.
DeleteSry its wrong in my book
ReplyDelete: )
DeleteD.update ({3 : "3"}) output and explanation please 🥺
ReplyDeleteIt will add or update the {3:"3"} in D dictionary.
DeleteYou are wrong, vi is wrong
ReplyDeletePlease provide explanation for the answers.
ReplyDeleteok, I have updated it.
Deletehi
ReplyDeleteyour web site is helping a lot in computer studies
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )