Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Simple Areas by gyahun_dash
from math import pi, sqrt
def circle(diameter):
return (diameter / 2)**2 * pi
def rectangle(width, height):
return width * height
def triangle(a, b, c: 'sides') -> "get area using Heron's formula":
s = (a + b + c) / 2 # semiperimeter
return sqrt(s * (s - a) * (s - b) * (s - c))
def simple_areas(*args):
area_function = {1: circle, 2: rectangle, 3: triangle}[len(args)]
return area_function(*args)
May 14, 2014
Comments: