Here is a snowflakes containing printable characters
from turtle import *
import random, string
fact = (2.0/(3.0*sqrt(3.0)), sqrt(3.0)/2.0, 0.5)
def writers(cx, cy, lengthside, levels):
if levels == 0:
penup()
goto(cx, cy)
pendown()
write(random.choice(string.printable))
return
r = lengthside * fact[0]
a = r * fact[1]
b = r * fact[2]
centers = [(cx, cy), (cx, cy+r), (cx, cy-r), (cx+a, cy+b), (cx+a, cy-b), (cx-a, cy+b), (cx-a, cy-b)]
for ux, uy in centers:
writers(ux, uy, lengthside/3.0, levels-1)
if __name__ == "__main__":
speed(0)
length = 500.0
writers(0.0, 0.0, length, 4)
mainloop()
Reputation Points: 930
Solved Threads: 668
Posting Maven
Offline 2,655 posts
since Jul 2008