Python画一个五星红旗

                                    

Python需要安装turtle库
没安装是用不了的

不要问我为什么这么长,拿图比着一个一个代码边敲试出来的能不长OvO
复制下面的代码到Python的开发环境idle或者直接复制到PyCharm运行

理解透彻后续更多内容关注我

import turtle as t#使用turtle库并简写名称为t
#红旗
t.setup(1500,1000,0,0)#设置窗口大小
t.pensize(2)#设置画笔大小
t.penup()#把画笔抬起
t.hideturtle()#隐藏画笔
t.goto(-400,-160)#将画笔移动到指定位置
t.pendown()#画笔落下
t.pencolor("yellow")#设置画笔颜色
t.fillcolor("red")#设置封闭图形的颜色
t.begin_fill()#开始上色
for i in range(2):#循环结构
    t.fd(700)#前进700像素
    t.left(90)#左转90度
    t.fd(450)#前进450像素
    t.left(90)
t.end_fill()
#大五星
t.pensize(0.5)
t.pencolor("yellow")
t.fillcolor("yellow")
t.penup()
t.goto(-329,183)
t.pendown()
t.hideturtle()
t.begin_fill()
for i in range(1):
    t.fd(45)
    t.left(70)
    t.fd(40)
    t.right(140)
    t.fd(40)
    t.left(70)
    t.fd(45)
    t.right(140)
    t.fd(45)
    t.left(70)
    t.fd(45)
    t.right(140)
    t.fd(45)
    t.left(60)
    t.fd(45)
    t.right(140)
    t.fd(45)
    t.left(72)
    t.fd(45)
t.end_fill()
#第一个小五星
t.pensize(0.5)
t.penup()
t.goto(-165,250)
t.pendown()
t.hideturtle()
t.pencolor("yellow")
t.fillcolor("yellow")
t.begin_fill()
t.right(175)
for q in range(1):
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(60)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(72)
    t.fd(15)
t.end_fill()
#第二个小五星
t.pensize(0.5)
t.penup()
t.goto(-95,195)
t.pendown()
t.hideturtle()
t.pencolor("yellow")
t.fillcolor("yellow")
t.begin_fill()
t.right(235)
for q in range(1):
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(60)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(72)
    t.fd(15)
t.end_fill()
#第三个小五星
t.pensize(0.5)
t.penup()
t.goto(-132,100)
t.pendown()
t.hideturtle()
t.pencolor("yellow")
t.fillcolor("yellow")
t.begin_fill()
t.right(305)
for q in range(1):
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(60)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(72)
    t.fd(15)
t.end_fill()
#第四个小五星
t.pensize(0.5)
t.penup()
t.goto(-145,70)
t.pendown()
t.hideturtle()
t.pencolor("yellow")
t.fillcolor("yellow")
t.begin_fill()
t.right(380)
for q in range(1):
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(70)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(60)
    t.fd(15)
    t.right(140)
    t.fd(15)
    t.left(72)
    t.fd(15)
t.end_fill()
t.done()

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值