forked from greenfox-zerda-lasers/trial-exam-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.py
More file actions
21 lines (16 loc) · 617 Bytes
/
3.py
File metadata and controls
21 lines (16 loc) · 617 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Create a class that represents a cuboid:
# It should take its three sizes as constructor parameters (numbers)
# It should have a method called `getSurface` that returns the cuboid's surface
# It should have a method called `getVolume` that returns the cuboid's volume
class Cuboid():
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def getSurface(self):
return 2 * (self.x * self.y + self.y * self.z + self.x * self.z)
def getVolume(self):
return self.x * self.y * self.z
cube = Cuboid(2, 3, 4)
print(cube.getSurface())
print(cube.getVolume())