Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c2f72b9

Browse files
Merge pull request #7 from binamify/main
Create inheritence.py
2 parents 73ebf81 + 547d464 commit c2f72b9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎OOP in Python/inheritence.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Animal:
2+
def speak(self):
3+
print("Animal Speaking")
4+
#The child class Dog inherits the base class Animal
5+
class Dog(Animal):
6+
def bark(self):
7+
print("dog barking")
8+
#The child class Dogchild inherits another child class Dog
9+
class DogChild(Dog):
10+
def eat(self):
11+
print("Eating bread...")
12+
d = DogChild()
13+
d.bark()
14+
d.speak()
15+
d.eat()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /