PYTHON CHAP 4 - Drawing With Turtles
PYTHON CHAP 4 - Drawing With Turtles
Creating a Canvas
Now that we have imported the turtle module, we need to create a
Canvas - a blank space to draw on, like an artist’s canvas. To do so,
we call the function Pen from the turtle module, which automatically
creates a canvas. Enter this into the Python shell:
>>> t = turtle.Pen()
>>> t = turtle.Pen()
import turtle
t = turtle.Pen()
t.forward(50)
t.left(90)
import turtle t.backward(100)
t = turtle.Pen() t.up()
t.right(90)
t.forward(50) t.forward(20)
t.left(90) t.left(90)
t.forward(50) t.down()
t.left(90) t.forward(100)
t.forward(50)
t.left(90)
t.forward(50)
t.reset()
A Box Without Corners
Write a program to draw the four lines shown here (the
size isn’t important, just the shape):
TIPS
#importing turtle module
import turtle