# File: tcircle.py # program to plot several circles # # Matt Bishop, ECS 36A, Winter 2019 # import turtle # # create a screen and a turtle # wn = turtle.Screen() tortoise = turtle.Turtle() # first, draw a circle of radius 50 tortoise.penup() tortoise.hideturtle() tortoise.goto(-220,0) tortoise.showturtle() tortoise.pendown() tortoise.circle(50) # now, a half circle of the same radius # the curve starts where the turtle is tortoise.penup() tortoise.hideturtle() tortoise.goto(-110, 0) tortoise.showturtle() tortoise.pendown() tortoise.circle(50,180) # a half circle drawn counterclockwise tortoise.penup() tortoise.hideturtle() tortoise.goto(0, 100) tortoise.showturtle() tortoise.pendown() tortoise.circle(50,180) # now a quarter circle, drawn clockwise tortoise.penup() tortoise.hideturtle() tortoise.goto(110, 0) tortoise.showturtle() tortoise.pendown() tortoise.circle(50,-90) # a 60 degree arc tortoise.penup() tortoise.hideturtle() tortoise.goto(170, 50) tortoise.showturtle() tortoise.pendown() tortoise.circle(50,-60) # ok, done with the turtle! tortoise.hideturtle() # draw red lower line tortoise.penup() tortoise.pencolor("red") tortoise.goto(-270, 0) tortoise.pendown() tortoise.goto(270,0) # draw red upper line tortoise.penup() tortoise.pencolor("red") tortoise.goto(-270, 100) tortoise.pendown() tortoise.goto(270,100) # draw dashed middle line tortoise.penup() tortoise.pencolor("red") for i in range(0,68): tortoise.goto(-270 + i * 8, 50) if i % 2 == 0: tortoise.pendown() tortoise.goto(-270 + (i+1) * 8,50) tortoise.penup() # now we wait for the window to close wn.mainloop()