Arrays · 19 / 23 Exercise Medium

On-screen circumference

Objective

Create a Python program that generates the drawing of a circle on the screen, dividing it into 360 equidistant points. Use the provided formula below to calculate radians. To position each point on the circle, you can use the angle value and calculate the corresponding x and y coordinates to draw the circle.

The necessary formula is:

radians = angle * PI / 180

Drawing. Use a matrix of 17 rows by 35 columns filled with spaces and, for each of the 360 angles (0, 1, ..., 359), place an X in column x = 17 + 16 * cos(radians) and row y = 8 + 8 * sin(radians), rounding both to the nearest integer (math.floor(value + 0.5)). Then print the 17 rows (trailing spaces are ignored). The program reads no input.

Output
            XXXXXXXXXXX
        XXXX           XXXX
     XXXX                 XXXX
    XX                       XX
   XX                         XX
  X                             X
 XX                             XX
 X                               X
 X                               X
 X                               X
 XX                             XX
  X                             X
   XX                         XX
    XX                       XX
     XXXX                 XXXX
        XXXX           XXXX
            XXXXXXXXXXX

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise