-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_pyramidV1.py
42 lines (29 loc) · 1.31 KB
/
create_pyramidV1.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
import math
class Pyramid:
def __init__(self, base_length, height, num_sides):
self.base_length = base_length
self.height = height
self.num_sides = num_sides
def volume(self):
return (1 / 3) * self.base_length ** 2 * self.height
def surface_area(self):
base_area = self.base_length ** 2
side_area = self.base_length * self.num_sides * self.height / 2
return base_area + side_area
def calculate_blocks_for_pyramid(pyramid, block_length, block_width, block_height):
# Calculate the volume of one block
block_volume = block_length * block_width * block_height
# Calculate the total surface area of the pyramid
pyramid_surface_area = pyramid.surface_area()
# Calculate the number of blocks required
num_blocks = pyramid_surface_area / block_volume
return num_blocks
# Define the dimensions of one block (in meters)
block_length = 0.1
block_width = 0.1
block_height = 0.1
# Create an instance of a pyramid with a square base (4 sides)
my_pyramid = Pyramid(230.4, 146.6, num_sides=4)
# Calculate the number of blocks needed
blocks_needed = calculate_blocks_for_pyramid(my_pyramid, block_length, block_width, block_height)
print("The number of blocks needed to build the pyramid is approximately {} blocks.".format(int(blocks_needed)))