What is inheritance?

Python classes and OOP · Freshers

Model answer

A class can inherit attributes and methods from a parent: class Admin(User). The child can add or override behaviour and call the parent with super(). Use it for real "is a" relationships, and prefer composition when you only want to reuse code.

Learn this topic

Classes and Objects in Python: A Gentle Introduction in the course Python for Beginners: Learn to Code with Real Projects.

Sign in to add your own answer.

More questions