Examveda

What will be the output of the following Python code?
class test:
    def __init__(self):
        self.variable = 'Old'
        self.Change(self.variable)
    def Change(self, var):
        var = 'New'
obj=test()
print(obj.variable)

A. Error because function change can't be called in the __init__ function

B. 'New' is printed

C. 'Old' is printed

D. Nothing is printed

Answer: Option C


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

Join The Discussion

Related Questions on Classes and Objects in Python