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 #298
class A(object):
x = 1
class B(A):
pass
class C(A):
pass
B.x = 2
A.x = 3
print(A.x, B.x, C.x)
In this case, when x changes for A , it also changes for C as C inherits from A and x is not specifically declared in A . (srikanthtechnologies.com/blog/python/mro.aspx)
What is the output of the code snippet below?
— The Python Quiz (@thepythonquiz) October 16, 2020
class A(object):
x = 1
class B(A):
pass
class C(A):
pass
B.x = 2
A.x = 3
print(A.x, B.x, C.x)
1 2 3
3 2 1
3 2 3#python #python3 #pythonprogramming #learnpython
Question difficulty: π΅π΅π΅π΅π΅