class Foo:
X = 10
def hello(self):
self.X = 20
f = Foo()
f.hello()
print(Foo.X, f.X)
Options:
Explanation
Correct answer is : D
Assigning to an object’s attribute always changes that object.
In method hello() , we are setting value 20 to self.X i.e. self.X = 20.
But the class attribute "X" value will be remain same as 10
Comment here: