single Inheritance in PYTHON

amannarayanm · October 18, 2021 · Python
# base class

class university:
    university_name = "Mumbai University"
    def myfun(self):
        print("\nHello This is Base Class")


class college(university):
    College_name = "Saket College Arts, Science and Commerce"
    def myfoo(self):
        print("\nDekho, This is Child class")
        
c1 = college()
c1.myfoo()
c1.myfun()
print(c1.university_name)
print(c1.College_name)
c1.College_name = "GyanPeath Saket"
print(c1.College_name)
print(college.College_name)

Comments

Please sign up or log in to contribute to the discussion.