An Equilateral Triangle
Run the program below. You will probably wonder why we turn by
1200...
DETAILS
Well... it's simple. The initial angle is
00, and to get the
supplement of the
600 angle,
we apply the geometric formula
1800 -
600 =
1200:
So, after moving forward
100 pixels, we turn by
1200 and draw the second side. We turn again by
1200 and return to the starting point by moving forward
100 pixels again.
Geometry is cool!
EXERCISES
Try to draw a trapezoid with the characteristics shown below:
Then, can you draw the shapes below?
Choose your own dimensions and colors!
Note, the web graphic screen is
300 pixels high, and you start from the center, so only
150 are visible upwards...
Pen Up, Pen Down!
The turtle can lift its pen so that it doesn't draw while it moves.
Use the functions
penup() (pen up) and
pendown() (
default, pen down) for this!
This way, you can move around the screen...
Test the following program in the editor to understand the mechanism:
import turtle
t = turtle.Turtle()
t.forward(30)
t.penup()
t.forward(30)
t.pendown()
t.forward(30)
t.penup()
t.forward(30)
t.pendown()
t.forward(30)
Command Shortcuts
We can use
fd() instead of
forward(),
bk() instead of
backward(),
as well as
lt() or
rt(),
pu() or
pd()...
Try to solve the proposed exercise,
then proceed to the next page.