+ 1
Polygon area
formula of polygon area if all side of polygon is equal: (n * s ^ 2) / 4 * tan(Ï / n) where n is number of side of polygon and s is side's length can someone correct my code please import math sides = int(input("number of side >> ")) sides_l = int(input("side length >> ")) a = math.pi / sides p_area = sides * sides_l ** 2 / 4 * math.tan(a) print(f"number of side: {sides} side length: {sides_l} area of polygon: {round(p_area, 3)}") first input: 6 second input: 5 #expect output 64.952 #my output 21.637 why my answer is not match with expect answer ?
2 Answers
+ 6
ăăŁă”ăȘăł ,
use the formula this way:
...
p_area = sides * (sides_l ** 2) / (4 * math.tan(a))
...
+ 1
Lothar
sorry. i didn't notice that there is a parenthesis cover all last part of formula
thank you! you save my day!