Lesson 13: Drawing letter S with Turtle

posted Jan 21, 2020, 10:08 AM by Attila Lengyel
import turtle
def draw_s(t, x, y):
min_y = 100000
max_y = -100000
t.penup()
t.setpos(x, y)
t.pendown()
t.left(90)

for i in range(27):
t.left(10)
t.forward(1)
if t.ycor() < min_y:
min_y = t.ycor()
if t.ycor() > max_y:
max_y = t.ycor()

for i in range(27):
t.right(10)
t.forward(1)
if t.ycor() < min_y:
min_y = t.ycor()
if t.ycor() > max_y:
max_y = t.ycor()
print(min_y, max_y)

bob = turtle.Turtle()
draw_s(bob, -130,130)
Comments