-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuper.py
45 lines (32 loc) · 990 Bytes
/
super.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
## Example 1 #######
# class Phone:
# def __init__(self, price, brand, camera):
# print("inside phone constructure")
# self.price = price
# self.__brand = brand
# self.camera = camera
# def buy(self):
# print("Buying a Phone")
# class SmartPhone(Phone):
# def buy(self):
# print("Buying a Smartphone")
# super().buy()
# s = SmartPhone(20000, "Apple", 13)
# s.buy()
##### Example 2 ############
class Phone:
def __init__(self, price, brand, camera):
print("inside phone constructor")
self.__price = price
self.brand = brand
self.camera = camera
class SmartPhone(Phone):
def __init__(self, price, brand, camera, os, ram):
print("First inside this")
super().__init__(price, brand, camera)
self.os = os
self.ram = ram
print("Inside Smartphone Constructor")
s = SmartPhone(20000, "Apple", 13, "Android", 2)
print(s.os)
print(s.brand)