Python - Volume of Right Pentagonal Pyramid
by matt392 in Design > Software
59 Views, 1 Favorites, 0 Comments
Python - Volume of Right Pentagonal Pyramid
print ("This program will calculate the volume of a right pentagonal pyramid. ")
import math
# Formula for calculating the volume of a right pentagonal pyramid:
# VolumeRightPentagonalPyramid = ((5/12) * (math.tan(54 degrees) * (height) * (BaseEdge**2))
###########################################
# 1 function: solve for the volume
# math.tan(x in radians) - returns tangent of "x" in radians
# Function to solve for the volume
# Enter the length of the base edge and height
# VolumeRightPentagonalPyramid = ((5/12) * (math.tan(54 degrees) * (height) * (BaseEdge**2))
def SolveForVolumeRightPentagonalPyramid():
print ("Solving for the volume of a right pentagonal pyramid.")
# math.tan(x in radians) - returns tangent of "x" in radians
# Enter the length of the base edge and height
BaseEdge = float(input("Enter the length of the base edge: ") )
height = float(input("Enter the height: ") )
# Change 54 degrees to radians so that we can use the math.tan function
# Use math.radians() to convert degrees to radians
FiftyFourInRadians = math.radians(54)
print("54 in radians is: ", FiftyFourInRadians)
# Now find the tangent
Tangent54 = math.tan(FiftyFourInRadians)
print("The tangent of 54 is: ", Tangent54)
# Break equation into parts to make it easier to calculate
VolumeRightPentagonalPyramid = ((5/12) * (Tangent54) * (height) * (BaseEdge**2))
print("Volume of the right pentagonal pyramid is: ", VolumeRightPentagonalPyramid)
ContinueCalculations = "y"
# Check to see if the user wants to continue to calculate the volume of a Right Pentagonal Pyramid
while (ContinueCalculations=="y"):
SolveForVolumeRightPentagonalPyramid()
ContinueCalculations = input("Would like to do another calculation for the volume of a Right Pentagonal Pyramid? (y/n): ")
print("==================================")
print ("Thank you to www.Google.com for assistance with this formula.")