给你一面国旗 教你用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批量合并有合并单元格的Excel文件详解

Python批量合并有合并单元格的Excel文件详解

合并单元格 合并单元格相信大家都会,比如下面这段简单的代码就可以实现: app='Word' word=win32.gencache.EnsureDispatch('%s.Appl...

Python魔法方法 容器部方法详解

这篇文章主要介绍了Python魔法方法 容器部方法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 为了加深印象,也为了以后能够更好...

浅谈Django中的数据库模型类-models.py(一对一的关系)

如下所示: # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import...

Python设计模式之状态模式原理与用法详解

Python设计模式之状态模式原理与用法详解

本文实例讲述了Python设计模式之状态模式原理与用法。分享给大家供大家参考,具体如下: 状态模式(State Pattern):当一个对象的内在状态改变时允许改变其行为,这个对象看起来...

Django实现学生管理系统

Django实现学生管理系统

Django学习笔记-学生管理系统(Django实现)笔记中仅实现了对数据的全部查询。 下面实现新增、删除、修改,代码如下。 下面的代码没有对输入框内容进行限制,如果输入不符合规则的内容...