import turtle
window = turtle.Screen()
window.setup(800, 600)
window.bgcolor("blue")
window.title("Kermit Window")
turtle.width(10)
turtle.color("orange")
turtle.up()
turtle.setpos(-80,-50)
turtle.down()
turtle.left(90)
turtle.fd(100)
turtle.right(135)
turtle.fd(45)
turtle.left(90)
turtle.fd(45)
turtle.right(135)
turtle.fd(100)
turtle.up()
turtle.left(90)
turtle.fd(20)
turtle.left(90)
turtle.down()
turtle.fd(100)
turtle.up()
turtle.left(180)
turtle.fd(50)
turtle.down()
turtle.left(90)
turtle.fd(45)
turtle.left(90)
turtle.fd(50)
turtle.left(180)
turtle.up()
turtle.fd(50)
turtle.down()
turtle.fd(50)
Class Exercise | Write Initials with Python / Turtle
Homework Exercise | Draw a Snowman with Python / Turtle
# Snowman
#
# Author: Mitch Harper
# Date: April 5, 2020
# Input: nothing
# Output: Snowman
#
#
# Import necessary libraries
import turtle as t
# Setup turtle & window
sc = t.Screen()
sc.setup(500,700)
sc.bgcolor("light blue")
sc.title("Kermit the Snowman")
t.speed(0)
# Define snowman body
def snow(size,scale,xloc,yloc):
currentpos = yloc
t.fillcolor("white")
for i in range(0,3):
t.pu()
t.setpos(xloc,currentpos)
t.pd()
t.begin_fill()
t.circle(size)
currentpos += size * 2
size *= scale
t.end_fill()
# Define arms
def arms(width,length,angle,xloc,yloc):
t.color("black")
t.width(width)
# left arm
t.up()
t.setpos(xloc,yloc)
t.seth(-90)
t.setpos(xloc,yloc)
t.left(angle)
t.down()
t.fd(length)
t.left(180)
t.fd(20)
t.right(90)
t.fd(20)
t.right(180)
t.fd(20)
t.left(45)
t.fd(20)
t.up()
# right arm
t.seth(-90)
t.setpos(-xloc,yloc)
t.right(angle)
t.down()
t.fd(length)
t.left(180)
t.fd(20)
t.right(90)
t.fd(20)
t.right(180)
t.fd(20)
t.left(45)
t.fd(20)
t.up()
# Define coal lumps
def coal(color,size,xloc,yloc):
t.color(color)
t.pu()
t.setpos(xloc,yloc)
t.pd()
t.begin_fill()
t.circle(size)
t.end_fill()
t.pu()
# Create snowman body
snow(100,0.75,0,-200)
# Create snowman face
coal ("black",5,0,200)
coal ("black",5,15,215)
coal ("black",5,-15,215)
coal ("black",5,0,180)
coal ("black",5,10,180)
coal ("black",5,-10,180)
coal ("black",5,20,185)
coal ("black",5,-20,185)
# Create snowman arms
arms(5,100,100,70,100)
# Exit on click
sc.exitonclick()