In: Computer Science
Write a function that draw your initials. (Using python 3 turtle) (T, S)
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
#code
import turtle
#method that draws initials T and S using turtle t
def drawInitials(t):
#using 5 as pen size, use higher values for
more thickness
t.pensize(5)
#moving forward 100 spaces
t.forward(100)
#moving backward 50 spaces
t.backward(50)
#turning right 90 degrees
t.right(90)
#moving forward 120 spaces
t.forward(120)
#T is complete by now,
#pen up
t.up()
#turning left 90 degrees
t.left(90)
#moving forward 150 spaces
t.forward(150)
#you are at bottom left corner of S
t.down()
#moving forward 50 spaces
t.forward(50)
#drawing a semi circle with radius 30 to
represent
#below portion of 'S'
t.circle(30,180)
#moving forward 25 spaces
t.forward(25)
#turning right 180 degrees
t.right(180)
# drawing a semi circle with radius 30 to
represent
# upper portion of 'S', in opposite
direction
t.circle(30, -180)
#moving backward 50 spaces, S is now
complete
t.backward(50)
#creating a turtle, setting maximum speed
t=turtle.Turtle()
t.speed(0)
#pen up, moving to a starting location
t.up()
t.goto(-100,100)
#pen down
t.down()
#drawing initials
drawInitials(t)
#hiding turtle
t.ht()
#finishing drawing
turtle.done()
#output