The quiz where the difficulty automagically adapts to the player's Python knowledge
This is a question page. You can use this page to bookmark a question. Start a new quiz!
Question #716
A dictionary can be copied using the built-in methods dict() or copy() . dict1.items() returns a list of tuples containing the key-value pairs of dict1 . Those are also a valid argument to pass to dict() to create a copy of dict1 . A dictionary cannot be copied directly with dict2 = dict1 as dict2 will then only be a reference to dict1 and changes made in dict1 will automatically also be made in dict2 . (w3schools.com/python/python_dictionaries.asp)
Which one is not a correct way of creating a copy of a dictionary?
— The Python Quiz (@thepythonquiz) December 28, 2020
dict2 = dict1.copy()
dict2 = dict(dict1.items())
dict2 = dict(dict1)
dict2 = dict1
None of the above#python #python3 #pythonprogramming #learnpython
Question difficulty: π΅π΅π΅π΅π΅