class ParentClass:
def __init__(self):
self.var = "I am a member of ParentClass"
def parent_method(self):
print("I am a method of ParentClass")
class ChildClass(ParentClass):
def __init__(self):
super().__init__()
self.var = "I am a member of ChildClass"
def child_method(self):
print("I am a method of ChildClass")
#Creating an instance of ChildClass
child_obj = ChildClass()
#Accessing variable from parent class
print(child_obj.var) # Output: I am a member of ChildClass
#Calling method from parent class
child_obj.parent_method() # Output: I am a method of ParentClass
#Calling method from child class
child_obj.child_method() # Output: I am a method of ChildClass