python3 turtle画正方形、矩形、正方体、五角星、奥运五环
python3 环境
turtle模块
分别画出
正方形、矩形、正方体、五角星、奥运五环
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Hiuhung Wan import turtle turtle.screensize(400, 400) #正方形
turtle.penup()
turtle.goto(-350,250)
turtle.pendown()
turtle.pencolor('green')
turtle.begin_fill()
turtle.fillcolor('green')
for i in range(4):
turtle.forward(80)
turtle.left(90)
turtle.end_fill() #矩形
turtle.penup()
turtle.goto(-200, 250)
turtle.pendown()
turtle.pencolor('blue')
turtle.begin_fill()
turtle.fillcolor('blue')
for i in range(1, 5):
if i % 2 == 1:
n = 120
elif i % 2 == 0:
n = 80
turtle.forward(n)
turtle.left(90) turtle.end_fill()
turtle.penup() #正方体
x = 0
y = 200
n = 80
turtle.goto(x, y)
turtle.pendown()
turtle.pencolor('black')
turtle.begin_fill()
turtle.fillcolor('black')
for i in range(4):
turtle.forward(n)
turtle.left(90)
turtle.end_fill()
turtle.penup()
turtle.goto(x, y + n)
turtle.pendown()
turtle.fillcolor('gray')
turtle.begin_fill()
turtle.left(45)
turtle.forward(int(n * 0.6)) #上方左侧斜线
turtle.right(45)
turtle.forward(n) #上方横线
turtle.left(360 - 135)
turtle.forward(int(n * 0.6)) ##上方右侧斜线
turtle.end_fill() turtle.left(45)
turtle.penup()
turtle.goto(x + n, y) turtle.pendown()
turtle.left(135)
turtle.forward(int(n * 0.6))
turtle.left(45)
turtle.forward(n)
turtle.right(90) #方向还原,向左
turtle.penup() #五角星
turtle.goto(x + 200, y)
turtle.pendown()
turtle.pencolor('orange')
turtle.begin_fill()
turtle.fillcolor('orange')
turtle.left(36)
for i in range(5):
turtle.forward(120)
turtle.left(180 - 36)
turtle.end_fill()
turtle.right(36)
turtle.penup() # -----------------------------------------------------
#奥运五环 x = -300
y = 50
r = 60
#第一个圈,蓝色
turtle.goto(x, y)
turtle.pendown()
turtle.pensize(15)
turtle.pencolor('blue')
turtle.circle(r)
turtle.penup() #第二个圈,黑色
turtle.goto(x + 2.5 * r , y)
turtle.pendown()
turtle.pensize(15)
turtle.pencolor('black')
turtle.circle(r)
turtle.penup() #第三个圈,红色
turtle.goto(x + 2.5 * r * 2 , y)
turtle.pendown()
turtle.pensize(15)
turtle.pencolor('red')
turtle.circle(r)
turtle.penup() #第四个圈,黄色
turtle.goto(x + (2.5 * r) * 0.5 , y - r)
turtle.pendown()
turtle.pensize(15)
turtle.pencolor('yellow')
turtle.circle(r)
turtle.penup() #第五个圈,绿色
turtle.goto(x + (2.5 * r) * 0.5 + 2.5 * r, y - r)
turtle.pendown()
turtle.pensize(15)
turtle.pencolor('green')
turtle.circle(r)
turtle.penup() turtle.done()
效果图:

python3 turtle画正方形、矩形、正方体、五角星、奥运五环的更多相关文章
- python3 turtle 画国际象棋棋盘
python3 turtle 画国际象棋棋盘 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wan import turt ...
- python3 turtle 画围棋棋盘
python3 环境 利用turtle模块画出 围棋棋盘 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wan impor ...
- 【Python】【demo实验29】【练习实例】【使用turtle画五角星】
原题: 使用turtle画五角星: 我的代码: #!/usr/bin/python # encoding=utf-8 # -*- coding: UTF-8 -*- from turtle impor ...
- Python3 turtle安装和使用教程
Python3 turtle安装和使用教程 Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x.纵轴为y的坐标系原点,(0,0)位置开始,它根据一组函数 ...
- HTML5之Canvas画正方形
HTML5之Canvas画正方形 1.设计源码 <!DOCTYPE html> <head> <meta charset="utf-8" /> ...
- 用div画三角/矩形/圆
1. 画三角 <!DOCTYPE html> <html> <head> <title></title> <meta charset= ...
- python运用turtle 画出汉诺塔搬运过程
python运用turtle 画出汉诺塔搬运过程 1.打开 IDLE 点击File-New File 新建立一个py文件 2.向py文件中输入如下代码 import turtle class Stac ...
- day 03 turtle 画鹅
turtle 画鹅 import turtle t=turtle turtle.speed(10) t. setup(800,600) #画头 turtle.penup() turtle.goto(0 ...
- *【Python】【demo实验31】【练习实例】【使用turtle画小猪佩奇】
如下图小猪佩奇: 要求使用turtle画小猪佩奇: 源码: # encoding=utf-8 # -*- coding: UTF-8 -*- # 使用turtle画小猪佩奇 from turtle i ...
随机推荐
- Dynamics CRM2013/2015 插件注冊工具登录后无法显示assembly列表问题的解决的方法
自微软从2013版本号推出新的插件注冊器后,随着UI的重大更新后,问题也多了非常多.前面已有博客提到注冊assembly时看不到注冊button(http://blog.csdn.net/vic022 ...
- 53.遇到SyntaxError: Unexpected token
转自:https://segmentfault.com/q/1010000002649920/a-1020000002655984 不知道你自己现在已经发现问题没, Unexpected token ...
- JS实现下拉菜单的功能
<!DOCTYPE html> <html> <head> <meta charset = "utf8"> <title> ...
- 【t038】&&【u214】金字塔
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 小X来到一个雄奇的金字塔挖宝,但是这是一座被诅咒的金字塔,小X必须马上逃离这里,否则小X就会被埋在金字 ...
- 内存卡(TF或其它)的标准
内存卡(TF或其它)的标准 来源 https://zh.wikipedia.org/wiki/SDXC 一般的内存卡是SD2.0的规范的,就是 Class10(10M/sec)或低于 Class10 ...
- js37---Function.prototype
//给函数的prototype新增名字为name,函数体为fn的函数 Function.prototype.method =function(name,fn){ this.prototype[name ...
- eclipse个人插件
1.SVN eclipse markets 安装m2e-subversion.svnkit 2.maven 本地装好mvn prefences导入maven安装目录和配置 3.单元测试覆盖率 EclE ...
- Mysql基本增删改查
1登陆服务器 mysql -h localhost -u username -p password 2查看存在数据库 show databases; 3创建一个数据库(例如名字为class1,以下都是 ...
- c#操作ElasticSearch5详解
c#操作ElasticSearch详解 ElasticSearch系列学习 ElasticSearch第一步-环境配置 ElasticSearch第二步-CRUD之Sense ElasticSearc ...
- 4.使用 WSDL 指定的标准 SOAP 消息格式
转自:https://technet.microsoft.com/zh-cn/sysinternals/x2ccke44(v=vs.94) 为 XML 文档(定义 Web 服务)定义架构的行业标准 W ...