0% found this document useful (0 votes)
2 views3 pages

Python Inheritance Tasks

The document outlines various tasks related to Python inheritance, categorized into single level, multilevel, hierarchical, multiple, and hybrid inheritance. Each task specifies the creation of classes and methods, demonstrating different inheritance types and their functionalities. The tasks include creating classes like Person, Vehicle, Company, Animal, Account, and others, along with their respective methods and object interactions.

Uploaded by

jvishnu3848
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Python Inheritance Tasks

The document outlines various tasks related to Python inheritance, categorized into single level, multilevel, hierarchical, multiple, and hybrid inheritance. Each task specifies the creation of classes and methods, demonstrating different inheritance types and their functionalities. The tasks include creating classes like Person, Vehicle, Company, Animal, Account, and others, along with their respective methods and object interactions.

Uploaded by

jvishnu3848
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Inheritance – Tasks

1. SINGLE LEVEL INHERITANCE


--------------------------------------------------
TASK 1:
Create a class Person with:
- variable name
- method show_name()

Create a class Student inheriting Person with:


- variable roll_no
- method show_student() that prints name and roll number

--------------------------------------------------
TASK 2:
Create:
- class Vehicle with method start()
- class Car with method drive()

Access both methods using Car object.

--------------------------------------------------
2. MULTILEVEL INHERITANCE
--------------------------------------------------
TASK 3:
Create classes:
- Company → method company_name()
- Department → method dept_name()
- Employee → method emp_details()

Create Employee object and access all methods.

--------------------------------------------------
TASK 4:
Create:
- Animal → eat()
- Mammal → walk()
- Dog → bark()

Access all methods using Dog object.


--------------------------------------------------
3. HIERARCHICAL INHERITANCE
--------------------------------------------------
TASK 5:
Create:
- Account → account_type()
- SavingsAccount → interest()
- CurrentAccount → overdraft()

Create objects for both child classes.

--------------------------------------------------
TASK 6:
Create:
- Employee → salary()
- Manager → bonus()
- Developer → coding()

Call parent method from both child classes.

--------------------------------------------------
4. MULTIPLE INHERITANCE
--------------------------------------------------
TASK 7:
Create Father and Mother classes with property methods.
Create Child class inheriting both and access both methods.

--------------------------------------------------
TASK 8 (Method Conflict):
Create:
- class A → show()
- class B → show()
- class C(A, B)

Create object of C and:


- call show()
- print [Link]()

--------------------------------------------------
5. HYBRID INHERITANCE
--------------------------------------------------
TASK 9:
Create:
- School → school_name()
- Teacher(School) → subject()
- Student(School) → roll_no()
- Monitor(Teacher, Student) → duty()

Access all methods using Monitor object.

You might also like