Found some fun turtle graphics online! Type in the below code into IDLE to find out what the mystery Turtle image is! Try changing the numbers – What happens? Which line would we change to change the size? How do we change the color?
Mystery Turtle Image #1
import turtle
spiral = turtle.Turtle()
for i in range(20):
spiral.forward(i * 10)
spiral.right(144)
turtle.done()
Mystery Turtle Image #2
from turtle import *
color('red','yellow')
begin_fill()
while True:
forward(200)
left(170)
if abs(pos()) < 1:
break
end_fill()
done()
Mystery Turtle Image #3
import turtle
ninja = turtle.Turtle()
ninja.speed(10)
for i in range(180):
ninja.forward(100)
ninja.right(30)
ninja.forward(20)
ninja.left(60)
ninja.forward(50)
ninja.right(30)
ninja.penup()
ninja.setposition(0, 0)
ninja.pendown()
ninja.right(2)
turtle.done()
No comments:
Post a Comment