用python画出圣诞树_【闲趣】如何用python画出一棵圣诞树
C语言你会了,python你会不会?
import turtle
screen = turtle.Screen()
screen.setup(800,600)
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, 17):
y = 30*i
for j in range(i-k):
x = 30*j
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 += 2
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(17,20):
y =30*i
for j in range(3):
x = 30*j
square.goto(x,-y+280)
square.stamp()
square.goto(-x,-y+280)
square.stamp()
【用python画出圣诞树_【闲趣】如何用python画出一棵圣诞树】turtle.exitonclick()
推荐阅读
- windows监控|【闲趣】python监控主动外连的异常行为
- 分布式技术专题线程间的高性能消息框架-深入浅出Disruptor的使用和原理
- Java技术指南「并发编程专题」CompletionService框架基本使用和原理探究(基础篇
- WordPress可视编辑器中的自定义样式不会将类应用于链接元素
- sklearn|python机器学习基础02——sklearn之KNN
- 神经网络|使用Python+OpenCV+Keras实现植物幼苗分类(附python演练)
- Typora 标题的自动编号
- 鸿蒙开源全场景应用开发——视频编解码
- “自定义存档”页面不适用于日期或标签,但适用于类别
- 计算用户点击WordPress中的按钮的次数