-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassTask.py
More file actions
78 lines (52 loc) · 1.31 KB
/
classTask.py
File metadata and controls
78 lines (52 loc) · 1.31 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
69
70
71
72
73
74
75
76
77
78
class Thing:
pass
print(Thing)
example = Thing()
print(example)
class Thing2:
def __init__(self):
self.letters = 'abc'
classThing2 = Thing2()
print(classThing2.letters)
class Thing3:
def __init__(self):
self.letters = 'xyz'
print(Thing3().letters)
class Element:
def __init__(self, name, symbol, number):
self.name = name
self.symbol = symbol
self.number = number
def dump(self):
print(self.name, self.symbol, self.number)
def __str__(self):
return self.name + ' ' + self.symbol + " " + str(self.number)
perEl = Element('Hydrogen', 'H', 1)
print(perEl.name, perEl.symbol, perEl.number)
propDict = {
'name': 'Hydrogen',
'symbol': 'H',
'number': 1
}
hydrogen = Element(**propDict)
print(hydrogen.name, hydrogen.symbol, hydrogen.number)
hydrogen.dump()
print(hydrogen)
class Laser:
def does(self):
return 'disentegrate'
class Claw:
def does(self):
return 'cruch'
class Smartphone:
def does(self):
return 'ring'
class Robot(Laser, Claw, Smartphone):
def does(self):
return Laser().does() + ' ' + Claw().does()+ ' ' + Smartphone().does()
laser = Laser()
claw = Claw()
smartphone = Smartphone()
robot = Robot()
print(laser.does(), claw.does(), smartphone.does())
print(robot.does())