-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass Practice II.py
More file actions
68 lines (43 loc) · 2.46 KB
/
Class Practice II.py
File metadata and controls
68 lines (43 loc) · 2.46 KB
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
60
61
62
63
64
65
66
67
68
# Practice, practice and more practice, practice.
class Class_act:
def __init__(self,attribute1,attribute2):
self.attribute1 = attribute1 # attribute1 property:
self.attribute2 = attribute2 # attribute2 property:
def return_value(variable_value):
return 'Returned Variable Value from Class_act.'
class Superclass1(Class_act): # inherit the 'Class_act' attribute properties:
# no redundant attribute properties:
def __init__(self,attribute1,attribute2):
super().__init__(attribute1,attribute2)
# inherit the 'Class_act' attribute properties and create two new attribute properties:
class Superclass2(Class_act):
def __init__(
self,attribute1,attribute2,attribute3,attribute4):
super().__init__(attribute1,attribute2)
self.attribute3 = attribute3 # new attribute3 property:
self.attribute4 = attribute4 # new attribute4 property:
class_attribute_values = Class_act(
'I am the attribute property value of attribute1',
'I am the attribute property value of attribute2') # two argument values:
superclass1_attribute_values = Superclass1(
'I am the attribute property value of attribute1',
'I am the attribute property value of attribute2') # two argument values:
superclass2_attribute_values = Superclass2(
'I am the attribute property value of attribute1',
'I am the attribute property value of attribute2',
'I am the attribute property value of attribute3',
'I am the attribute property value of attribute4') # four argument values:
a = Class_act.return_value('argument placeholder')
b = Superclass1.return_value('argument placeholder')
c = Superclass2.return_value('argument placeholder')
print(class_attribute_values.attribute1) # attribute1 property from Class_act:
print(class_attribute_values.attribute2) # attribute2 property from Class_act:
print(superclass1_attribute_values.attribute1) # same attribute1 property from Class_act:
print(superclass1_attribute_values.attribute2) # same attribute2 property from Class_act:
print(superclass2_attribute_values.attribute1) # same attribute1 property from Class_act:
print(superclass2_attribute_values.attribute2) # same attribute2 property from Class_act:
print(superclass2_attribute_values.attribute3) # new attribute3 property from superclass2_attribute_values:
print(superclass2_attribute_values.attribute4) # new attribute4 property from superclass2_attribute_values:
print(a)
print(b)
print(c)