Python编写五星红旗

1.导入海龟库

import turtle

2.绘制旗面

##绘制旗面
turtle.penup()
turtle.goto(-300,-200)
turtle.pendown()
turtle.color("red")
turtle.begin_fill()
turtle.forward(600)
turtle.left(90)
turtle.forward(400)
turtle.left(90)
turtle.forward(600)
turtle.left(90)
turtle.forward(400)
turtle.left(90)
turtle.end_fill()

3.绘制大五角星

turtle.color("gold")
turtle.begin_fill()
turtle.penup()
turtle.goto(-260,120)
turtle.pendown()
for i in range(5):
    turtle.forward(120)
    turtle.right(144)
turtle.end_fill()

4.绘制第一个小五角星

turtle.color("gold")
turtle.begin_fill()
turtle.penup()
turtle.goto(-120,160)
turtle.pendown()
for i in range(5):
    turtle.forward(40)
    turtle.right(144)
turtle.end_fill()

5.绘制第二个小五角星

##第二个小五角星
turtle.color("gold")
turtle.begin_fill()
turtle.penup()
turtle.goto(-80,120)
turtle.pendown()
for i in range(5):
    turtle.forward(40)
    turtle.right(144)
turtle.end_fill()

6.绘制第三个小五角星

turtle.color("gold")
turtle.begin_fill()
turtle.penup()
turtle.goto(-80,60)
turtle.pendown()
for i in range(5):
    turtle.forward(40)
    turtle.right(144)
turtle.end_fill()

7.绘制第四个小五角星

turtle.color("gold")
turtle.begin_fill()
turtle.penup()
turtle.goto(-120,20)
turtle.pendown()
for i in range(5):
    turtle.forward(40)
    turtle.right(144)
turtle.end_fill()

8.隐藏画笔

turtle.hideturtle()
turtle.done()

9.完整代码

import turtle

##绘制旗面
turtle.penup()
turtle.goto(-300,-200)
turtle.pendown()
turtle.color("red")
turtle.begin_fill()
turtle.forward(600)
turtle.left(90)
turtle.forward(400)
turtle.left(90)
turtle.forward(600)
turtle.left(90)
turtle.forward(400)
turtle.left(90)
turtle.end_fill()

##大五角星
turtle.color("gold")
turtle.begin_fill()
turtle.penup()
turtle.goto(-260,120)
turtle.pendown()
for i in range(5):
    turtle.forward(120)
    turtle.right(144)
turtle.end_fill()

##第一个小五角星
turtle.color("gold")
turtle.begin_fill()
turtle.penup()
turtle.goto(-120,160)
turtle.pendown()
for i in range(5):
    turtle.forward(40)
    turtle.right(144)
turtle.end_fill()

##第二个小五角星
turtle.color("gold")
turtle.begin_fill()
turtle.penup()
turtle.goto(-80,120)
turtle.pendown()
for i in range(5):
    turtle.forward(40)
    turtle.right(144)
turtle.end_fill()

##第三个小五角星
turtle.color("gold")
turtle.begin_fill()
turtle.penup()
turtle.goto(-80,60)
turtle.pendown()
for i in range(5):
    turtle.forward(40)
    turtle.right(144)
turtle.end_fill()

##第四个小五角星
turtle.color("gold")
turtle.begin_fill()
turtle.penup()
turtle.goto(-120,20)
turtle.pendown()
for i in range(5):
    turtle.forward(40)
    turtle.right(144)
turtle.end_fill()
turtle.haideturtle()
turtle.done()

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值