Define a function calc_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
Volume for 4.5, 2.1, 3.0 is: 9.45
Relevant geometry equations:
Volume = base area x height x 1/3
Base area = base length x base width.

given to me
''' Your solution goes here '''
length = float(input())
width = float(input())
height = float(input())
print('Volume for', length, width, height, "is:", calc_pyramid_volume(length, width, height))

Respuesta :

The missing segment of the code illustrates the use of functions.

Functions are also referred to as procedures or methods; they are set of instructions that act as one.

The code segment that complete the code in the question is as follows:

def calc_pyramid_volume(length, width, height):

   baseArea = length * width

   Volume = baseArea * height * 1/3

   return Volume

The first line of the code segment declares the function itself

def calc_pyramid_volume(length, width, height):

Then, the base area of the pyramid is calculated

   baseArea = length * width

Then, the volume of the pyramid is calculated

   Volume = baseArea * height * 1/3

Lastly, the volume is returned to the main method

   return Volume

So, the complete code (without comments) is:

def calc_pyramid_volume(length, width, height):

   baseArea = length * width

   Volume = baseArea * height * 1/3

   return Volume

   

length = float(input())

width = float(input())

height = float(input())

print('Volume for', length, width, height, "is:", calc_pyramid_volume(length, width, height))

See attachment for the sample run

Read more about functions at:

https://brainly.com/question/17225124

Ver imagen MrRoyal
ACCESS MORE