209k views
0 votes
Define a function pyramid_volume with parameters base_length, base_width, and pyramid_height, that returns the volume of a pyramid with a rectangular base. Sample output with inputs: 4.5 2.1 3.0

User Mike Allen
by
8.0k points

1 Answer

0 votes

Answer:

def pyramid_volume(base_length, base_width, pyramid_height):

base_area = base_length * base_width

volume = 1 / 3 * base_area * pyramid_height

return volume

Step-by-step explanation:

Create a function called pyramid_volume that takes base_length, base_width, pyramid_height as parameters

The formula to calculate the volume of a pyramid is = 1/3Ah, A is the base area, h is the height

Inside the function, calculate the base area, multiply base_length with base_width. Then, calculate the volume using the formula. Return the volume

User Leila Hamon
by
7.6k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.