Python - Volume of Icosahedron (20-sided Sphere)

by matt392 in Circuits > Software

45 Views, 1 Favorites, 0 Comments

Python - Volume of Icosahedron (20-sided Sphere)

VolumeIcosahedron.jpg
print ("This program will calculate the volume of an icosahedron.  ")

import math

#  Formula for calculating the volume of an icosahedron:
#  IcosahedronVolume =  (5/12) * (3+math.sqrt(5)) * (edge**3)
###########################################

# 1 function: solve for the volume
# math.sqrt(x) - returns square root of "x"
# Function to solve for the volume
# Enter the length of the edge 
# IcosahedronVolume =  (5/12) * (3+math.sqrt(5)) * (edge**3)

def SolveForVolumeIcosahedron():
    print ("Solving for the Volume of an Icosahedron.")
#  Square root function: math.sqrt(x)
    edge = float(input("Enter the length of the edge: ") )
    Volume = (5/12) * (3+math.sqrt(5)) * (edge**3)
   
    print("The volume of the icosahedron is: ", Volume)
ContinueCalculations = "y"

# Check to see if the user wants to continue to calculate the volume of an icosahedron
while (ContinueCalculations=="y"):
    SolveForVolumeIcosahedron()
    ContinueCalculations = input("Would like to do another calculation for the the volume of an icosahedron? (y/n): ")
    
print("==================================")
print ("Thank you to www.FxSolver.com for assistance with this formula.")