Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulrichzwingli/0c29b15f358b9246123446bb44db79f8 to your computer and use it in GitHub Desktop.
Save ulrichzwingli/0c29b15f358b9246123446bb44db79f8 to your computer and use it in GitHub Desktop.
Exploring Turtle : Random images
from turtle import *
import random
colors = ['orange', 'yellow', 'red', 'green', 'blue','cyan']
for n in range(50):
penup()
goto(random.randint(-400, 400), random.randint(-400, 400))
pendown()
distance = random.randint(10, 40)
pensize(random.randint(1, 5))
for i in range(n+5):
fillcolor(colors[i % 6])
begin_fill()
forward(distance)
setheading(i)
forward(n*5)
goto(0,0)
end_fill()
penup()
goto(random.randint(-400, 400), random.randint(-400, 400))
pendown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment