欢迎使用CSDN-markdown编辑器
2015-09-07 15:17
585 查看
python 版本:3.4.3
import 模块:turtle
使用turtle模块绘制多边图形,代码如下:
运行结果如图:
本程序关键是turtle.circle(radius, extent, steps)方法的参数设置
radius:指定所绘圆形的半径
extent:指定绘制多大角度的圆形
steps:指定圆形边数(3,4,5,6…)
import 模块:turtle
使用turtle模块绘制多边图形,代码如下:
#-*- charset:utf-8 -*- import turtle #设置画笔笔迹宽度 turtle.pensize(3) #画三边形 turtle.color("red") turtle.penup() turtle.goto(-200,-50) turtle.pendown() turtle.circle(40, steps=3) #画四边形 turtle.color("green") turtle.penup() turtle.goto(-100,-50) turtle.pendown() turtle.circle(40, steps=4) #画五边形 turtle.color("blue") turtle.penup() turtle.goto(0,-50) turtle.pendown() turtle.circle(40, steps=5) #画六边形 turtle.color("yellow") turtle.penup() turtle.goto(100,-50) turtle.pendown() turtle.circle(40, steps=6) #画圆形 turtle.color("purple") turtle.penup() turtle.goto(200,-50) turtle.pendown() turtle.circle(40) turtle.done()
运行结果如图:
本程序关键是turtle.circle(radius, extent, steps)方法的参数设置
radius:指定所绘圆形的半径
extent:指定绘制多大角度的圆形
steps:指定圆形边数(3,4,5,6…)
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python将excel导入到mysql中
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- Python 七步捉虫法