Here is a subset of the possible solutions for drawing the polygons in this assignment. Please keep in mind that there are multiple correct ways of programming each of these figures.

The following programs draw the polygons without using Repeat Loops.

All of the regular polygons below have sides of 6 cm.

###

####

####

###

The following programs draw the polygons without using Repeat Loops.

**1. Square of sides 8 cm:**

Fd 8

Rt

Fd 8

Rt

Fd 8

Rt

Fd 8

**2. Rectangle 4 cm x 6 cm:**

Fd 4

Rt

Fd 6

Rt

Fd 4

Rt

Fd 6

**3. Parallelogram 4 cm x 6 cm:**Fd 4

Rt 45

Fd 6

Rt 135

Fd 4

Rt 65

Fd 6

**4. Rhombus 6 cm:**Fd 6

Rt 60

Fd 6

Rt 120

Fd 6

Rt 60

Fd 6

**5. Equilateral Triangle of sides 6 cm:**Fd 6

Rt 120

Fd 6

Rt 120

Fd 6

**6. Right Triangle of sides 3 cm, 4 cm, 5 cm:**Fd 3

Rt 126

Fd 5

Rt 144

Fd 4

### Drawing Regular Polygons using Repeat Loops in Pro-Bot

All of the regular polygons below have sides of 6 cm.

**1. Equilateral Triangle**Rpt 3 [

Fd 6

Rt 120

]

**2. Square**Rpt 4 [

Fd 6

Rt 90

]

// You can also use the instruction "Rt", instead of "Rt 90" in the code above, // as the default turn is 90 degrees for Pro-Bot.

**3. Pentagon**Rpt 5 [

Fd 6

Rt 72

]

**4. Hexagon**Rpt 6 [

Fd 6

Rt 60

]

**5. Octagon**Rpt 8 [

Fd 6

Rt 45

]

**6. Nonagon**Rpt 9 [

Fd 6

Rt 40

]

**7. Decagon**Rpt 10 [

Fd 6

Rt 36

]

####
**A Circle using a Repeat Loop**

###
Rpt 360 [

Fd 1 // Move 1 cm

Rt 1 // Turn 1 degree

]

Fd 1 // Move 1 cm

Rt 1 // Turn 1 degree

]

### An Algorithm for Drawing Regular Polygons using Repeat Loops

From the pieces of code above for various regular polygons, the relation between the number of sides of a regular polygon and the angle of turn can be deduced to 360/N where N is the number of sides of the polygon.

*The generalized algorithm for drawing regular polygons is:*

Rpt N [

Fd X

Rt 360/N

]

*where N is the number of sides of the regular polygon, X is the length of each side of the polygon.*
awesome job!

ReplyDelete