Examveda

What will be the output of the following Python code?
class change:
    def __init__(self, x, y, z):
        self.a = x + y + z
 
x = change(1,2,3)
y = getattr(x, 'a')
setattr(x, 'a', y+1)
print(x.a)

A. 6

B. 7

C. Error

D. 0

Answer: Option B


This Question Belongs to Python Program >> Classes And Objects In Python

Join The Discussion

Related Questions on Classes and Objects in Python