Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
someThing solution in Clear category for Humpty Dumpty Form by Adrian_W
import math
def checkio(height, width): # a szer c wys
a=width/2
c=height/2
if c>a:
e = (1 - (a*a)/(c*c))**(1/2)
area = 2*math.pi*a*a*(1 + c/(a*e) * math.asin(e))
elif a==c:
area = 4 * math.pi * a*c
else:
e = (1 - (c*c)/(a*a))**(1/2)
area = 2*math.pi*a*a*(1 + (1 - e*e)/e * math.atanh(e))
volume = (4/3)*a*a*c*math.pi
return [round(volume,2),round(area,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"
Nov. 11, 2016