from turtle import *
import random as r
import time
import turtle
screensize(bg=‘black’)
color(“orange”, “yellow”)
begin_fill()
left(126)
screen=turtle.Screen()
screen.setup(375,700)
circle=turtle.Turtle()
circle.shape(‘circle’)
circle.color(‘red’)
circle.speed(‘fastest’)
circle.up()
square=turtle.Turtle()
square.shape(‘square’)
square.color(‘green’)
square.speed(‘fastest’)
square.up()
circle.goto(0,280)
circle.stamp()
k=0
for i in range(1,13):
y=30i
for j in range(i-k):
x=30j
square.goto(x,-y+280)
square.stamp()
square.goto(-x,-y+280)
square.stamp()
if i%4==0:
x=30*(j+1)
circle.color(‘red’)
circle.goto(-x,-y+280)
circle.stamp()
circle.goto(x,-y+280)
circle.stamp()
k+=3
if i%4 ==3:
x=30*(j+1)
circle.color(‘yellow’)
circle.goto(-x,-y+280)
circle.stamp()
circle.goto(x,-y+280)
circle.stamp()
square.color(‘brown’)
for i in range(13,17):
y=30i
for j in range(2):
x=30j
square.goto(x,-y+ 280)
square.stamp()
square.goto(-x,-y+280)
square.stamp()
turtle.color(“dark red”,“red”)#定义字体颜色
turtle.write(“Merry Christmas”,align =“center”,font=(“Comic Sans MS”,40,“bold”))#定义文字、位置、字体、大小
def drawsnow():#定义画雪花的方法
turtle.ht() #隐藏笔头,ht=hideturtle
turtle.pensize(2) #定义笔头大小
for i in range(200): #画多少雪花
turtle.pencolor(“white”) #定义画笔颜色为白色,其实就是雪花为白色
turtle.pu() #提笔,pu=penup
turtle.setx(r.randint(-350,350)) #定义x坐标,随机从-350到350之间选择
turtle.sety(r.randint(-100,350)) #定义y坐标,注意雪花一般在地上不会落下,所以不会从太小的纵座轴开始
turtle.pd() #落笔,pd=pendown
dens = 6 #雪花瓣数设为6
snowsize = r.randint(1,10) #定义雪花大小
for j in range(dens): #就是6,那就是画5次,也就是一个雪花五角星
#t.forward(int(snowsize)) #int()取整数
turtle.fd(int(snowsize))
turtle.backward(int(snowsize))
#t.bd(int(snowsize)) #注意没有bd=backward,但有fd=forward,小bug
turtle.right(int(360/dens)) #转动角度
drawsnow()#调用画雪花的方法
turtle.done() # 完成,否则会直接关闭



