Fun with Flags – Part 1: flags and turtles

Step 3 – Square turtle

Now you can turn a turtle, you can draw a square.

Problem – draw a square

Code helper image
  1. Use this code as a starting point to draw a square using the turtle

    How many sides does a square have?

  2. Run your code and check that the turtle draws a square

Notice where the turtle ends up and what direction it's facing in. That might be important later on.

Notice that I added a line of code above my program to say what it does. The line starts with a hash symbol #.

This is a comment. Comments are used to tell people what the code does. The computer sees the hash symbol and ignores the rest of the line.

Comments are really useful to include in your code.

If right(90) is used to turn the turtle 90° to the right, how do you think you can turn the turtle to the left? Hint: it's not too tricky...