Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Humpty Dumpty Form by jcg
import math
def volum_spheroid(r,h) :
return 4*math.pi/3*r**2*h
def area_spheroid(r,h) :
if hr :
e = math.sqrt(1-r**2/h**2)
return 2*math.pi*r**2*(1+h/(r*e)*math.asin(e))
else :
return 4*math.pi*r**2
def checkio(h, w) :
return [round(volum_spheroid(w/2, h/2),2),round(area_spheroid(w/2,h/2),2)]
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(4, 2) == [8.38, 21.48], "Prolate spheroid"
assert checkio(2, 2) == [4.19, 12.57], "Sphere"
assert checkio(2, 4) == [16.76, 34.69], "Oblate spheroid"
Feb. 9, 2014