EZ Programing Demos

Slow motion, step by step, animated demonstrations of basic computer programing techniques

Links to topics:

Current topic:

Turtle graphics designs, square

Go forward, turn left 90 degrees. Repeat this 4 times and you have traced a square.

 Slow  Medium  Fast 
Click 'Run' to go.

When the turtle goes around a square, it will rotate a total of 360 degrees:

In the video above there are two turtles symbolized as arrows. The one on the right lets you see the turtle's rotation without regard to its movement. The total rotation is tallied beneath this turtle. Note that by the time the polygon, a square, is traversed by the turtle, the total angle through which the turtle has turned is 360 degrees. This turns out to be true for any convex polygon.


This picture shows each cycle of the repeat loop:


When the turtle executes lt 90, it is the external 90 degrees angle, not the internal 90 degrees angle.


Here's an animation showing the external angle being the turtle's turning angle:


You may be wondering about the reason for the last left 90 degree turn. It may seem useless since the drawing looks finished before the turn, but that last turn can be important.

The last left 90 degree turn returns the turtle to its initial direction, directly right. Returning the turtle to its initial direction can aid your thinking when connecting small diagrams into complicated designs.

Basically, with this the turtle ends up just like it started, in the same place, aimed in the same direction.


Here's the flowchart for the turtle's square demo:


This could look like the following in an imaginary computer language:



Suggested next article:

At EZ Math Movie

EZ Math Movie is a site that can help you experiment with and understand many topics in mathematics. Its main feature is an interactive animated (x, y) graph that you control with an actual programing language. There are many examples and tutorials, and EZ Math Movie is crossed referenced with both EZ Programing Demos and Zona Land Education.


Zona Land Education is a site with explanations and interactive diagrams covering many topics in physics and mathematics. Zona Land Education is cross referenced with EZ Math Movie, and it contains several animations that use EZ Math Movie's programing language.