Python小实例之欢度国庆

国庆节将至,今天在课上老师交给我们一个任务,那就是用Python创作出一个国旗来个祖国庆生,让我们来看看吧。

代码如下:

#National_Flag.py
import  turtle  
turtle.title("National_falg")
turtle.up()             #起笔
turtle.goto(-200,200)   #画笔从中心向x轴负方向移动200像素点,向y轴正方向移动200像素点
turtle.down()           #落笔
turtle.begin_fill()     #开始填充
turtle.fillcolor("red") #填充颜色为红色
turtle.pencolor("red")  #画笔颜色为红色
for i in range(2):      #设置循环为2
    turtle.forward(280) #画笔前进280像素点
    turtle.right(90)    #向右转90度
    turtle.forward(200) #画笔前进200像素点
    turtle.right(90)    #向右转90度
turtle.end_fill()       #停止填充
 
turtle.up()
turtle.goto(-170,145)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow")
for x in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()
 
turtle.up()
turtle.goto(-100,180)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow&
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值