Fork me on GitHub

Sarah's turtle

by Sarah Breen

10 Oct 2013

Tessie!

I like adding a colored background to the turtles - next time, I might let it auto select a color!

Screen shot 1 Screen shot 2

import turtle
import random

tessie = turtle.Turtle()

def random_color():
   color_value = format(random.randint(0, 16777215), '06x')
   return "#" + color_value

def random_location(turtle, x, y):
   random_x = random.randint(-x, x)
   random_y = random.randint(-y, y)
   turtle.setpos(random_x, random_y)

wn = turtle.Screen()
wn.bgcolor("dark blue")


for i in range(random.randint(0, 250)):
   turtle.left(random.randint(0, 175))
   turtle.forward(random.randint(25, 175))
   turtle.dot(random.randint(20, 75), random_color())
   turtle.forward(50)
   turtle.left(90)
   turtle.left(90)
   turtle.left(90)
   turtle.left(90)

turtle.done()   
Sarah is a first year MSIS student. Originally from Ohio, she has spent the last five years in Asia working in archives and as a project manager for several small organizations. Reach her on email at sburnham5@gmail.com. Find Sarah Breen on Twitter, Github, and on the web.
comments powered by Disqus