Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use a) d.delete(“john”:40) b) d.delete(“john”) c) del d[“john”]. d) del d(“john”:40) Answer : c) del d[“john”]....
Suppose d = { john :40, peter :45}, what happens when we try to retrieve a value using the expression d[ susan ]? a) Since susan is not a value in the set, Python raises a KeyError ... Python raises a KeyError exception d) Since susan is not a key in the set, Python raises a syntax error Answer : c) Since “susan” is not a key in the set, Python raises a KeyError exception...
Which of the following statements create a dictionary? a) d = {} b) d = {“john”:40, “peter”:45} c) d = {40:”john”, 45:”peter”} d) All of the mentioned Answer : d) All of the mentioned...
Which of the following statements create a dictionary? a) d = {} b) d = {“john”:40, “peter”:45} c) d = {40:”john”, 45:”peter”} d) All of the mentioned Answer : Answer: d Explanation: Dictionaries are created by specifying keys and values....
What will be the output? d = {"john":40, "peter":45} print(list(d.keys())) a) [“john”, “peter”]. b) [“john”:40, “peter”:45]. c) (“john”, “peter”) d) (“john”:40, “peter”:45) Answer : a) [“john”, “peter”]....
50.5k questions
47.1k answers
240 comments
7.0k users