How do you declare an instance variable in Python?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Declaring an instance variable in Python:
class school:
def __init__(self, name, age):
self.name = name # instance variable
self.age = age # instance variable
def disp(self):
print(self.name, self.age)
obj = school(“test”,25)
obj.disp()