给你一面国旗 教你用python画中国国旗

yipeiwu_com5年前Python基础

本文实例为大家分享了python画中国国旗的具体代码,供大家参考,具体内容如下

# author : momo
import turtle
#中国国旗
turtle.up()
turtle.goto(-200,200)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("red")
turtle.pencolor("red")
for i in range(2):
 turtle.forward(280)
 turtle.right(90)
 turtle.forward(200)
 turtle.right(90)
turtle.end_fill()
 
turtle.up()
turtle.goto(-170,145)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow")
for x in range(5):
 turtle.forward(50)
 turtle.right(144)
turtle.end_fill()
 
turtle.up()
turtle.goto(-100,180)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow")
for x in range(5):
 turtle.forward(20)
 turtle.right(144)
turtle.end_fill()
 
turtle.up()
turtle.goto(-70,160)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow")
for x in range(5):
 turtle.forward(20)
 turtle.right(144)
turtle.end_fill()
 
turtle.up()
turtle.goto(-70,120)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow")
for x in range(5):
 turtle.forward(20)
 turtle.right(144)
turtle.end_fill()
 
turtle.up()
turtle.goto(-100,100)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow")
for x in range(5):
 turtle.forward(20)
 turtle.right(144)
turtle.end_fill()
 
 
turtle.hideturtle()#隐藏小海龟
#维持面板
turtle.done()

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

一道python走迷宫算法题

一道python走迷宫算法题

前几天逛博客时看到了这样一道问题,感觉比较有趣,就自己思考了下方案顺便用python实现了一下。题目如下: 用一个二维数组表示一个简单的迷宫,用0表示通路,用1表示阻断,老鼠在每个点上可...

Python随机数random模块使用指南

random 模块是Python自带的模块,除了生成最简单的随机数以外,还有很多功能。 random.random() 用来生成一个0~1之间的随机浮点数,范围[0,10 >...

Python实现的统计文章单词次数功能示例

本文实例讲述了Python实现的统计文章单词次数功能。分享给大家供大家参考,具体如下: 题目是这样的:你有一个目录,放了你一个月的日记,都是 txt,为了避免分词的问题,假设内容都是英文...

Python实现在线程里运行scrapy的方法

本文实例讲述了Python实现在线程里运行scrapy的方法。分享给大家供大家参考。具体如下: 如果你希望在一个写好的程序里调用scrapy,就可以通过下面的代码,让scrapy运行在一...

使用Python的Turtle库绘制森林的实例

使用Python的Turtle库绘制森林的实例

这是由一个小作业引发的对Python的Turtle库的学习 下面是官方手册: Turtle官方手册 1.配置编程环境 由于现在的笔记本是临时借的,编程环境不是熟悉的环境,又由于种种原因...