Side of a regular n | Python 3 implementation of the approach ; Function to calculate the side of the polygon circumscribed in a circle ; Driver Code ; Total sides of the polygon ; Radius of the circumscribing circle
from math import sin NEW_LINE def calculateSide ( n , r ) : NEW_LINE INDENT theta = 360 / n NEW_LINE theta_in_radians = theta * 3.14 / 180 NEW_LINE return 2 * r * sin ( theta_in_radians / 2 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 NEW_LINE r = 5 NEW_LINE print ( ' { 0 : . 5 } ' . format ( calculateSide ( n , r ) ) ) NEW_LINE DEDENT