from math import * from random import random from turtle import * k = .01 for i in range(500): x, y, j = random(), random(), 0 while j < 40 and 0 < x < 1.2 and 0 < y < 1: penup() if j == 0 else pendown() goto(250 * x - 150, 250 * y - 120) xx, yy = 10*x-5, 10*y-5 dg = xx**2+yy**2 xp, yp = (dg-1)*(dg-9), dg-4 an = atan(yp / xp) if xx != 0 else pi / 2 * sgn(yy) pencolor((int(255*abs(an))% 255,)*3) x += k * cos(an) y += k * sin(an) j += 1 hideturtle()