Skip to content

Commit c4a1fab

Browse files
practice
1 parent 7b558c8 commit c4a1fab

2 files changed

Lines changed: 58 additions & 9 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# ------------------------------------------------
2+
# Example Program: Multiple Inheritance in Python
3+
# ------------------------------------------------
4+
5+
"""
6+
Inheritance Diagram
7+
8+
konda kondare
9+
│ │
10+
│ │
11+
└───────┬─────────┘
12+
13+
DerivedClass
14+
15+
Tiru()
16+
17+
Explanation:
18+
- 'konda' and 'kondare' are parent classes.
19+
- 'DerivedClass' inherits from both parent classes.
20+
- Therefore, DerivedClass can access methods from both parents.
21+
"""
22+
23+
# Parent Class 1
24+
class konda:
25+
26+
# Method inside the first parent class
27+
def reddy(self):
28+
print("Kondareddy")
29+
30+
31+
# Parent Class 2
32+
class kondare:
33+
34+
# Method inside the second parent class
35+
def Ambavaram(self):
36+
print("Tirumala")
37+
38+
39+
# Child Class inheriting from both parent classes
40+
# This demonstrates Multiple Inheritance
41+
class DerivedClass(konda, kondare):
42+
43+
# Method defined in the child class
44+
def Tiru(self):
45+
print("Ambavaram Tirumala Kondareddy")
46+
47+
48+
# Creating an object of the child class
49+
obj = DerivedClass()
50+
51+
# Calling method from Parent Class 1
52+
obj.reddy()
53+
54+
# Calling method from Parent Class 2
55+
obj.Ambavaram()
56+
57+
# Calling method from Child Class
58+
obj.Tiru()

OOPS/tempCodeRunnerFile.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)