python语言:五星红旗制作

这段Python代码使用turtle库来绘制中国五星红旗。用户可以输入国旗的放大倍数,程序会画出红色旗面和黄色五角星,包括一个大星星和四个小星星。
摘要由CSDN通过智能技术生成

五星红旗代码如下:

import turtle as tu

tu.hideturtle()     #隐藏海龟
tu.speed(10)
tu.title("Chinese National Flag.")   #显示海龟绘图窗口的标题栏文本

n = float(tu.textinput("N","Please enter the times you want."))       #国旗放大的倍数,textinput()函数用于返回用户输入的参数

#旗面
tu.penup()
tu.goto(-150*n,100*n)
tu.pendown()
tu.pencolor("red")
tu.begin_fill()
tu.fillcolor("red")
tu.fd(300*n)
tu.right(90)
tu.fd(200*n)
tu.right(90)
tu.fd(300*n)
tu.right(90)
tu.fd(200*n)
tu.end_fill()

#大星星
tu.penup()
tu.goto(-100*n,80*n)
tu.pendown()
tu.pencolor("yellow")
tu.begin_fill()
tu.fillcolor("yellow")
tu.setheading(-72)
for i in range(5):
    tu.fd(57.06*n)
    tu.right(144)
tu.end_fill()

#小星星1
tu.penup()
tu.goto(-60*n,70*n)
tu.pendown()
tu.pencolo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

她好不可耐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值