from turtle import * speed(1) # blue bg penup() goto(0, -250) pendown() color("lightskyblue") begin_fill() circle(250) end_fill() # tree trunk penup() goto(-15, -50) pendown() color("brown") begin_fill() for i in range(2): forward(30) right(90) forward(40) right(90) end_fill() # set the star position and the initial tree width y = -50 width = 240 height = 25 # greem part of the tree while width > 20: width = width - 30 # make the tree get smaller as it goes high x = 0 - width / 2 # set the starting x-value of each level of the tree color("green") penup() goto(x, y) pendown() begin_fill() for i in range(2): forward(width) left(90) forward(height) left(90) end_fill() y = y + height # keep drawing the level of the tree higher than the previous # star penup() goto(-15, 150) pendown() color("yellow") begin_fill() for i in range(5): forward(30) right(144) end_fill() # message penup() goto(-130, -150) color("red") write("MERRY CHRISTMAS" , font = ("Aharoni" , 25, "bold")) hideturtle()
Comments
Post a Comment