Skip to content

Commit

Permalink
formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
Karandeep Grover committed Jan 25, 2021
1 parent f5a1166 commit 9b9a589
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
24 changes: 16 additions & 8 deletions Basics/Hindi/17_inheritance/inheritace.py
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()
10 changes: 5 additions & 5 deletions Basics/Hindi/17_inheritance/inheritance.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## Exercise: Inheritance

1. create inheritance using animal dog relation.
1. create inheritance using animal Dog relation.


```
for example,
animal and dog both has same living_place so create a method for living_place
Animal and Dog both has same habitat so create a method for habitat
```

2. use super() constructor for calling parent constructor.

```
class animal:
class Animal:
#code
class dog(animal):
super()-it refers animal class,now you can call animal's methods.
class Dog(Animal):
super()-it refers Animal class,now you can call Animal's methods.
```

[Solution](https://github.com/codebasics/py/blob/master/Basics/python_basics/17_inheritance/17_inheritance.py)
Expand Down
23 changes: 13 additions & 10 deletions Basics/Hindi/18_multiple_inheritance/multiple_inheritance.py
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()

0 comments on commit 9b9a589

Please sign in to comment.