Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Humpty Dumpty Form by Jaime
from math import pi,sqrt,atanh,asin
def checkio(height, width):
v=round(((4*pi)/3)*(width/2)**2*(height/2),2)
if heightwidth:
e=sqrt(1-((width/2)**2)/((height/2)**2))
return [v,round(2*pi*(width/2)**2*(1+((height/2)/((width/2)*e))*asin(e)),2)]
return [v,round(4*pi*(width/2)**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"
Aug. 20, 2019