-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path51_inheritance.py
More file actions
36 lines (30 loc) · 853 Bytes
/
51_inheritance.py
File metadata and controls
36 lines (30 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#inheritance is a way of creating a new class from an existing class
'''
syntax:
class Employee:
#code --------->base class
class Programmer(Employee):
#code --------->derived class
'''
class Employee:
company="google"
def showdetails(self):
print('this is an employee')
class Programmer(Employee):
salary=10000000000
def getdata(self):
print("Vaish")
def showdetails(self): #overriding-in this the method is made in the child class also and when the same method is called from both the classes e.g showdetails() it will execute the method of child class
print('this is a programmer')
e=Employee()
e.showdetails()
p=Programmer()
p.getdata()
print(p.company)
p.showdetails()
'''
TYPES OF INHERITANCE
1)single inheritance
2)Multiple inheritance
3)Multilevel inheritance
'''