Python turtle海龟绘制美国队长盾牌

使用Python中的turtle模块绘制美队盾牌

具体思路如下:

  1. 导入海龟库
  2. 第1个圆:半径 200,红色填充
  3. 第2个圆:半径 150,白色填充
  4. 第3个圆:半径 100,红色填充
  5. 第4个圆:半径 50,蓝色填充

代码如下:(仅供参考,如有错误欢迎指正)

# 导入海龟库
import turtle
t=turtle.Turtle()
t.shape('turtle')
t.speed(0)

# 第一个圆:红色,半径200
t.up()
t.goto(0,-200)
t.down()
t.color('red')
t.begin_fill()
t.circle(200)
t.end_fill()

# 第二个圆:白色,半径150
t.up()
t.goto(0,-150)
t.down()
t.color('white')
t.begin_fill()
t.circle(150)
t.end_fill()

# 第三个圆:红色,半径100
t.up()
t.goto(0,-100)
t.down()
t.color('red')
t.begin_fill()
t.circle(100)
t.end_fill()

# 第四个圆:蓝色,半径50
t.up()
t.goto(0,-50)
t.down()
t.color('blue')
t.begin_fill()
t.circle(50)
t.end_fill()

# 画五角星
t.up()
t.goto(-40,15)
t.down()
t.color('white')
t.begin_fill()
for i in range(5):
    t.forward(80)
    t.right(144)
t.end_fill()

# 海龟隐藏hideturtle、显示show
t.hideturtle()
t.hideturtle()

运行效果

在这里插入图片描述

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
可以使用Python中的turtle库来画美国队长盾牌,具体步骤如下: 1. 导入turtle库: ```python import turtle ``` 2. 创建turtle窗口: ```python window = turtle.Screen() ``` 3. 创建turtle对象并设置画笔颜色、粗细等属性: ```python pen = turtle.Turtle() pen.pensize(5) pen.color("red", "blue") ``` 4. 画圆并填充颜色: ```python pen.begin_fill() pen.circle(100) pen.end_fill() ``` 5. 画五角星: ```python pen.penup() pen.goto(0, 170) pen.pendown() for i in range(5): pen.forward(60) pen.right(144) pen.penup() pen.goto(0, 0) pen.pendown() for i in range(5): pen.forward(60) pen.left(144) ``` 6. 添加美国队长盾牌的红色和白色条纹: ```python pen.penup() pen.goto(-120, 80) pen.pendown() pen.color("red") pen.begin_fill() pen.forward(240) pen.right(90) pen.forward(30) pen.right(90) pen.forward(240) pen.right(90) pen.forward(30) pen.end_fill() pen.penup() pen.goto(-120, 50) pen.pendown() pen.color("white") pen.begin_fill() pen.forward(240) pen.right(90) pen.forward(30) pen.right(90) pen.forward(240) pen.right(90) pen.forward(30) pen.end_fill() ``` 7. 完成绘制: ```python window.exitonclick() ``` 完整代码如下: ```python import turtle window = turtle.Screen() pen = turtle.Turtle() pen.pensize(5) pen.color("red", "blue") pen.begin_fill() pen.circle(100) pen.end_fill() pen.penup() pen.goto(0, 170) pen.pendown() for i in range(5): pen.forward(60) pen.right(144) pen.penup() pen.goto(0, 0) pen.pendown() for i in range(5): pen.forward(60) pen.left(144) pen.penup() pen.goto(-120, 80) pen.pendown() pen.color("red") pen.begin_fill() pen.forward(240) pen.right(90) pen.forward(30) pen.right(90) pen.forward(240) pen.right(90) pen.forward(30) pen.end_fill() pen.penup() pen.goto(-120, 50) pen.pendown() pen.color("white") pen.begin_fill() pen.forward(240) pen.right(90) pen.forward(30) pen.right(90) pen.forward(240) pen.right(90) pen.forward(30) pen.end_fill() window.exitonclick() ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

小脆筒style

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

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

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

打赏作者

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

抵扣说明:

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

余额充值