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 #132
import copy
a = [1, 2]
b = copy.deepcopy(a)
print(a[0] is b[0])
When copy.deepcopy() is used, the copy of the object has a new memory address and its elements have new memory addresses too. However, the elements of a here are not mutable and as such copy.deepcopy() returns a shallow copy (behaves like copy.copy() ). (towardsdatascience.com/assignment-shallow-or-deep-a-story...)
What is the output of the code snippet below?
— The Python Quiz (@thepythonquiz) August 21, 2020
import copy
a = [[1], [2]]
b = copy.deepcopy(a)
print(a[0] is b[0])
False
True#python #python3 #pythonprogramming #learnpython
Question difficulty: π΅π΅π΅π΅π΅
Similar questions: