-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path54 class_Inheritance.py
59 lines (45 loc) · 1.15 KB
/
54 class_Inheritance.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#Inheritance:: (Existing code ke babohar kora)
# Parent class, Super class, Base class
#Child class, Sub class, Derived Class
## Normal Code:
class Phone:
def call(self):
print("You can Call")
def message(self):
print("You can Message")
class Samsung:
def call(self):
print("You can Call")
def message(self):
print("You can Message")
def photo(self):
print("You can take Photo")
p = Phone()
p.message()
p.call()
s = Samsung()
s.call()
s.message()
s.photo()
print("=====--BREAK--=====")
## Code Using Inheritance:
class Phone:
def call(self):
print("You can Call")
def message(self):
print("You can Message")
class Samsung(Phone): #Phone er ekta catagory Samsung(Phone CLASS er boisisto Samsung e thakbe.)
#Class: Phone; Sub-Class: Samsung
def photo(self):
print("You can take Photo")
p = Phone()
p.message()
p.call()
s = Samsung()
s.call()
s.message()
s.photo()
### Sub-Class Check:
print(issubclass(Samsung,Phone))
# Right: (Sub-Class,Class)
print(issubclass(Phone,Samsung))