Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Oblate, Prolate or Sphere then Calculate solution in Clear category for Humpty Dumpty Form by John.Hammell
import math
def checkio(height, width):
c = float(height) / 2.0
a = float(width) / 2.0
if c < a: # Oblate Spheroid Surface Area
e2 = float(1 - ((c**2) / (a**2)))
e = float(math.sqrt(e2))
area = (2 * math.pi * (a**2)) * (1 + (((1 - e2)/(e)) * math.atanh(e)))
area = round(area, 2)
if c > a: # Prolate Spheroid Surface Area
e2 = float(1 - ((a**2) / (c**2)))
e = float(math.sqrt(e2))
area = (2 * math.pi * (a**2)) * (1 + (c / (a * e)) * math.asin(e))
area = round(area, 2)
if (c < a) or (c > a): # Oblate or Prolate Spheroid Volume
volume = ((4 * math.pi) / 3) * a**2 * c
volume = round(volume, 2)
if c == a: # Sphere Area & Volume
area = 4 * math.pi * a**2
area = round(area, 2)
volume = (4.0 / 3.0) * math.pi * a**3
volume = round(volume, 2)
return [volume, area]
Nov. 8, 2015
Comments: