-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path099_Program-_Inheritance.py
More file actions
24 lines (16 loc) · 1014 Bytes
/
099_Program-_Inheritance.py
File metadata and controls
24 lines (16 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Inheritance : is the process through which 'some existing methods' of a class is brought into another class
# Main purpose of 'inheritance' is to RE-USE THE EXISTING METHODS of a class into another class
class phone : # parent class / super class / base class
def call (self) : # (notice the sign beside code's serial no.)
print('You can call.')
def message (self) :
print('You can message.')
# child class / sub class / derived class
class xiaomi (phone) :
def photo (self) : # '(phone)' means importing the methods of 'phone' into the class 'xiaomi'
print('You can take photo.')
# Now the class 'xiaomi' is inheriting the methods of class 'phone'
x = xiaomi() # creating object
# calling both the method individually
x.call()
x.message()