forked from codebasics/py
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Karandeep Grover
committed
Jan 25, 2021
1 parent
f5a1166
commit 9b9a589
Showing
3 changed files
with
34 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
class Animal: | ||
def __init__(self, living_place): | ||
self.living_place = living_place | ||
def __init__(self, habitat): | ||
self.habitat = habitat | ||
|
||
def print_habitat(self): | ||
print(self.habitat) | ||
|
||
def sound(self): | ||
print("Some Animal Sound") | ||
|
||
def printplace(self): | ||
print(self.living_place) | ||
|
||
class Dog(Animal): | ||
def __init__(self, living_place): | ||
super().__init__(living_place) | ||
def __init__(self): | ||
super().__init__("Kennel") | ||
|
||
def sound(self): | ||
print("Woof woof!") | ||
|
||
x = Dog("zoo") | ||
x.printplace() | ||
|
||
x = Dog() | ||
x.print_habitat() | ||
x.sound() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 13 additions & 10 deletions
23
Basics/Hindi/18_multiple_inheritance/multiple_inheritance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
class Teacher(): | ||
def teachers_action(self): | ||
print('I can teach') | ||
class Teacher: | ||
def teachers_action(self): | ||
print("I can teach") | ||
|
||
|
||
class Engineer(): | ||
class Engineer: | ||
def Engineers_action(self): | ||
print('I can code') | ||
print("I can code") | ||
|
||
class Youtuber(): | ||
|
||
class Youtuber: | ||
def youtubers_action(self): | ||
print('I can code and teach') | ||
print("I can code and teach") | ||
|
||
|
||
class Person(Teacher, Engineer, Youtuber): | ||
pass | ||
|
||
|
||
class Person(Teacher, Engineer, Youtuber): | ||
pass | ||
coder = Person() | ||
coder = Person() | ||
coder.teachers_action() | ||
coder.Engineers_action() | ||
coder.youtubers_action() |