Challenge 2: Draw shapes

Suggested time: 20 minutes

A programmer is designing a program which should let you draw a regular polygon. A regular polygon is a shape where every side is the same length and all of the angles inside the shape are the same.

For example, a square is a regular polygon with 4 sides.

The program should ask the user how many sides the shape should have and how long each side should be as shown below:

The flowchart below shows how the program should function:

Flowchart showing how to draw a regular polygon

Using the file below:

Implement the flowchart so that the code shows the output shown below:
Do not add any additional functionality

Example program output

If this was a real question it would tell you to save your code as but you might want to save your code so you can show your teacher or come back to it later by pressing Ctrl + S or clicking on the icon that looks like this:

Save / share icon in lets you save your code