首页 > Python资料 博客日记

Python编写五星红旗

2024-10-18 18:00:05Python资料围观34

Python资料网推荐Python编写五星红旗这篇文章给大家,欢迎收藏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()


版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!

标签:

相关文章

本站推荐