Countdown to Christmas Makes Challenge 2017 – Day 17

Turtle Snowflake

Programmed in Python 3.x
using the Turtle library



Turtle Snowflake, coded in Python 3.x using the Turtle library.

Python 3.x Code

# Turtle Snowflake
# by @KariLawler (Twitter)
# Created: 17/Dec/2017, Version: 1.1, Edited: 18/Dec/2017
import turtle

turtle.setup(500, 500) # Set main window size
turtle.colormode(255)
turtle.bgcolor(135, 206, 235) # Set background colour / Skyblue

t = turtle.Turtle()
t.speed(3) # Set speed; Fastest = 0, Fast = 10, Normal = 6, Slow = 3, Slowest = 1
t.color(255, 255, 255) # Set pen colour / White
t.pensize(5) # Set pen size

for a in range(1, 7): # Loop 6 times, adjusting angle by 60 degrees
	t.forward(120)
	for b in range(1, 4): # Loop 3 times, increasing size
		t.backward(30)
		t.left(45)
		t.forward(b * 15)
		t.backward(b * 15)
		t.right(90)
		t.forward(b * 15)
		t.backward(b * 15)
		t.left(45)
	t.backward(30)
	t.right(60)

t.hideturtle() # Hide cursor/turtle
turtle.done()

Leave a Reply