Visitar URL original
Update MultilevelInheritance.md · VenkatAdd/PythonScript@0af71a7 · GitHub
Skip to content

Commit 0af71a7

Browse files
authored
Update MultilevelInheritance.md
1 parent f4ea0f4 commit 0af71a7

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

‎Class/MultilevelInheritance.md‎

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
### Introduction
44

55
- The features of all the base classes are inherited into the derived class We can inherit a derived class from another derived class, this process is known as multilevel inheritance.
6-
- This is an example of child and grand child relationship.
6+
- This is an example of a child and grandchild relationship.
77
- Multi-level inheritance is archived when a derived class inherits another derived class.
88
- There is no limit on the number of levels up to which, the multi-level inheritance is archived in python.
9-
- when we call a method using derived class and if thta method is not avialable in that derived class it will chek it in its parent class. if that methods is not present in parent class then it will search it from grand parent.
9+
- when we call a method using derived class and if that method is not available in that derived class it will check it in its parent class. if that method is not present in parent class then it will search it from a grandparent.
1010

1111
![Multilevel Inheritance](https://github.com/chavarera/PythonScript/blob/master/Class/multilevelinheritance.png)
1212

1313
### Algorithm
1414

15-
1.Create a Parent Class A.
15+
1. Create a Parent Class A.
1616
```python
1717
class A:
1818
```
@@ -24,25 +24,26 @@ class B(A):
2424
```python
2525
class C(B):
2626
```
27-
4.Repeat this process untill you Required.
27+
4. Repeat this process until you Required.
2828

29-
5.Create object of last derived class and access methods and attributes of all above parent and grand parent class.
29+
5. Create an object of last derived class and access methods and attributes of all the above parent and grandparent class.
3030

3131
### Syntax
3232
```python
3333
#Parent Class For B
3434
class <A>:
35-
#initilize attributes and methods
35+
#initilize attributes and methods
36+
3637
#Child Class for Class A And Parent class For Class C
3738
class <B>(A):
38-
#initilize class b cand call constructor of class A
39+
#initilize class b cand call constructor of class A
3940

4041
#Child class for B
4142
class <C>(B):
42-
#call the constructor of class B
43-
#Access here Allthe properties of class A and Class B
43+
#call the constructor of class B
44+
#Access here All the properties of class A and Class B
4445

45-
#Create objec of C Class
46+
#Create an object of C Class
4647
c1=C()
4748
```
4849

@@ -60,10 +61,14 @@ class C(B):
6061
B.__init__(self)
6162
print(self.Avar)
6263
b1=C()
63-
64-
#Result:I am A Class variable
64+
```
65+
Output:
66+
```
67+
I am A Class variable
6568
```
6669

70+
71+
6772
### Example 2
6873
```python
6974
#Parent Class A
@@ -103,8 +108,9 @@ class C(B):
103108

104109
#create object of C class
105110
b1=C()
106-
107-
'''
111+
```
112+
Output
113+
```
108114
#Result
109115
---------------------In Class C----------------------------
110116
--------------Class A variable--------------
@@ -118,5 +124,4 @@ I am B Class variable
118124
---------The variable from first parent class---------
119125
120126
20
121-
'''
122127
```

0 commit comments

Comments
 (0)