1. Make an angle: `pen red`

draws in red;
`fd 100`

moves forward; and `rt 72`

turns
right by 72°.

pen red# Start drawing in red.fd 100# Move forward by 100 pixels.rt 72# Turn right by 72 degrees.fd 100# Move forward by 100 again.

The command `rt 72`

turns the turtle, but it does not
slide it. To draw an angle, move forward after turning.

- How big is the drawn angle? The 72 degree turtle turn is the
*supplement*of the drawn angle. - Experiment with other angle sizes. How big is the angle using
`rt 5`

?

2. The angle that measures a turtle turn is called an
*exterior angle*. The following special line of code
will load a script "/lib/angles.cs" that puts the turtle in
a mode that shows all exterior angles when the turtle turns.
It waits to finish loading the script before running the rest
of your program.

await loadscript '/lib/angles.cs', defer()pen red # Start drawing in red. fd 100 # Move forward by 100 pixels. rt 72 # Turn right by 72 degrees. fd 100 # Move forward by 100 again.rt 72# Turn right by 72 degrees.fd 100# Move forward by 100 again.

You could copy-and-paste the code five times to repeat it five
times. Or you can have the program repeat the
steps automatically, using a *loop*.

3. Make a loop. Unlike LOGO, which used
"repeat" to make a loop, CoffeeScript uses the word `for`

.
Indent the block of code and then
write `for [1..5]`

above it, to loop 5 times.

await loadscript '/lib/angles.cs', defer() pen red # Start drawing in red.for [1..5]# Repeat 5 timesfd 100 # Move forward by 100 pixels.rt 72 # Turn right by 72 degrees.

It is important to line up indented lines neatly in CoffeeScript:
the language uses indenting to know which block of lines to repeat
under a `for`

.

4. Finally, experiment with variables. We will use `s`

as the length of a side, and `n`

as the number of sides,
and `a`

as the measure of an exterior angle.

await loadscript '/lib/angles.cs', defer()s = 80# s is the side length.n = 6# n is the number of sides.a = 60# a is the exterior angle size. pen red # Start drawing in red. for [1..n] # Repeat n times fds# Move forward by s pixels. rta# Turn right by a degrees.

5. Exercises:

- Try shrinking
`s`

down to a size smaller than 10.

What do you notice about the exterior angles all together? - What is the sum of all the exterior angles of a polygon? Why?
- What does
`a`

need to be to make a polygon when`n`

is 3? - What should
`a`

be when`n`

is 10? - Find a formula for
`a`

in terms of`n`

. Change your program to use the formula.

s = 200 n = 9 a = 360 * 4 / 9 bk 100 pen blue for [1..n] fd s rt a pen null jump(-500, 100) await loadscript '/lib/angles.cs', defer() s = 10 n = 6 a = 60 pen red for [1..n] fd s rt a

6. Extra Credit:

- What would it mean for the turtle to turn a total of 720 degrees?
- Try setting
`n`

to 5 and`a`

to 144, and make`s`

80. Why do you get the shape that you get? - Can you make a nine-pointed star?
- How many different nine-pointed star shapes can you create?