Wednesday, October 28, 2015 7:38 PM

Python Return (Activity 6.3.2)

Python
Question:
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.

Relevant geometry equations:
Volume = base area x height x 1/3
Base area = base length x base width.
(Watch out for integer division). 
 
Code:
def pyramid_volume(base_length,base_width,pyramid_height):
    base_area=base_length*base_width
    pyramid_volume=base_area*pyramid_height*1/3
    return pyramid_volume
 
print('Volume for 4.5, 2.1, 3.0 is:', pyramid_volume(4.5, 2.1, 3.0)) 

About Unknown

Here you can share some biographical information next to your profile photo. Let your readers know your interests and accomplishments.

1 comment: