Turtle Letters: 01
Draw a T
Part of a series of tutorial articles about drawing symbols with turtle graphics.
Code examples referred to on this page can be found here: https://github.com/ucsb-cs8-m17/Lecture3_0810
Here is some code that draws the letter T with a given width and height.
This code makes the assumption that your turtle is called t
.
def drawT(width,height):
'''
draw a T
assume turtle facing east (0), and leave it facing east
assume pen is down
no assumptions about position.
'''
t.forward (width)
t.backward (width/2)
t.right (90)
t.forward (height)
t.left(90)
Here’s a full Python file that draws a T:
import turtle
t = turtle.Turtle()
def drawT(width,height):
'''
draw a T
assume turtle facing east (0), and leave it facing east
assume pen is down
no assumptions about position.
'''
t.forward (width)
t.backward (width/2)
t.right (90)
t.forward (height)
t.left(90)
drawT(50,100)
Turtle Graphics letters tutorials: table of contents
Section | Code (github repo) |
Topics Covered |
---|---|---|
Turtle Letters: 01 | code | Draw a T |
Turtle Letters: 02 | code | Drawing an A |
Turtle Letters: 03 | code | The bounding box, reference point, and Drawing an O (or a 0) |
Turtle Letters: 04 | Planning your letters inside a bounding box (planning P and C) |