Python Test 9 - Dictionary Which of the following statements create a dictionary?d = {“john”:40, “peter”:45}d = {40:”john”, 45:”peter”}d = {}All of the mentioned What will be the output of the following Python code snippet? d = {"john":40, "peter":45}“john” and “peter”“john”, 40, 45, and “peter”40 and 45d = (40:”john”, 45:”peter”) What will be the output of the following Python code snippet? d = {"john":40, "peter":45} "john" in dErrorNoneFalseTrue What will be the output of the following Python code snippet? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 == d2ErrorFalseTrueNone What will be the output of the following Python code snippet? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 > d2NoneTrueFalseError What will be the output of the following Python code snippet? d = {"john":40, "peter":45} d["john"]“peter”“john”4540 Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use?del d(“john”:40)del d[“john”]d.delete(“john”)d.delete(“john”:40) Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do we use?len(d)d.size()d.len()size(d) What will be the output of the following Python code snippet? d = {"john":40, "peter":45} print(list(d.keys()))(“john”:40, “peter”:45)[“john”, “peter”][“john”:40, “peter”:45](“john”, “peter”) Suppose d = {“john”:40, “peter”:45}, what happens when we try to retrieve a value using the expression d[“susan”]?Since “susan” is not a key in the set, Python raises a syntax errorSince “susan” is not a key in the set, Python raises a KeyError exceptionSince “susan” is not a value in the set, Python raises a KeyError exceptionIt is executed fine and no exception is raised, and it returns None Schreibe einen Kommentar Antworten abbrechenDu musst angemeldet sein, um einen Kommentar abzugeben.