Dashed radii meet the vertices; the hexagon's side equals the radius.import math
from fractions import Fraction
import sympy as sp
pi = sp.pi
sqrt = sp.sqrt
deg = math.pi / 180.0
def fmt(v):
f = float(v)
return str(int(round(f))) if abs(f - round(f)) < 1e-9 else f'{f:.2f}'
from sympy import Rational, nsimplify
R = 8
hex_area = 3 * sqrt(3) / 2 * R**2
circ_area = pi * R**2
ratio = sp.simplify(circ_area / hex_area)
answer = float(ratio)
print('ANSWER=' + f'{answer:.3f}')
print('TRAP_RADIUS_AS_HEIGHT=' + fmt(pi * R**2 - 3 * sqrt(3) / 4 * R**2))
print('TRAP_RING_OF_RINGS=' + fmt(pi * R**2 - hex_area * 2))
print('TRAP_AREA_RATIO_ONLY=' + fmt(circ_area / hex_area * 2))
Only each person's first answer, given before viewing the solution, is counted.
Discussion 0 comments
Log in to join the discussion.