用python画玫瑰花教程-使用Python画一朵玫瑰花
# -*- coding: utf-8 -*-# @Time : 18-9-14 下午3:23# @Author : Felix Wangimport turtleimport mathdef p_line(t, n, length, angle): """Draws n line segments.""" for i in range(n): t.fd(length) t.lt(angle)def polygon(t, n, length): """Draws a polygon with n sides.""" angle =360/ n p_line(t, n, length, angle)def arc(t, r, angle): """Draws an arc with the given radius and angle.""" arc_length = 2 * math.pi * r * abs(angle) /360n = int(arc_length / 4) + 1 step_length = arc_length / n step_angle = float(angle) / n # Before starting reduces, making a slight left turn. t.lt(step_angle / 2) p_line(t, n, step_length, step_angle) t.rt(step_angle / 2)def petal(t, r, angle): """Draws a 花瓣 using two arcs.""" for i in range(2): arc(t, r, angle) t.lt(180 - angle)def flower(t, n, r, angle, p): """Draws a flower with n petals.""" for i in range(n): petal(t, r, angle) t.lt(p / n)def leaf(t, r, angle, p): """Draws a 叶子 and fill it.""" t.begin_fill() # Begin the fill process. t.down() flower(t, 1, r, angle, p) t.end_fill()def main(): window = turtle.Screen() # creat a screen window.bgcolor("white") window.title("draw a flower") lucy = turtle.Turtle() lucy.shape("turtle") lucy.color("red") lucy.width(3) # lucy.speed(10) # Drawing flower flower(lucy, 7, 60, 100,360) # Drawing pedicel lucy.color("brown") lucy.rt(90) lucy.fd(200) # Drawing leaf 1 lucy.width(1) lucy.rt(270) lucy.color("green") leaf(lucy, 40, 80, 180) lucy.rt(140) lucy.color("black") lucy.fd(30) lucy.lt(180) lucy.fd(30) # Drawing leaf 2 lucy.rt(120) lucy.color("green") leaf(lucy, 40, 80, 180) lucy.color("black") lucy.rt(140) lucy.fd(30) lucy.ht() # hideturtle window.exitonclick()main()
用python画玫瑰花教程-使用Python画一朵玫瑰花相关推荐
- python菜鸟基础教程-python基础菜鸟教程,Python的基础语法
原标题:python基础菜鸟教程,Python的基础语法 什么是Python?Python是一门简单直观的编程语言,并且目前是开源的,可以方便任何人使用. Python的开发哲学:用一种方法,最好是只 ...
- Python人脸识别教程 - 基于Python的开源人脸识别库:离线识别率高达99.38%
Python人脸识别教程 - 基于Python的开源人脸识别库:离线识别率高达99.38% 仅用 Python 和命令行就可以实现人脸识别的库开源了.该库使用 dlib 顶尖的深度学习人脸识别技术构建 ...
- python基础教程菜鸟教程-python基础菜鸟教程,Python的基础语法
原标题:python基础菜鸟教程,Python的基础语法 什么是Python?Python是一门简单直观的编程语言,并且目前是开源的,可以方便任何人使用. Python的开发哲学:用一种方法,最好是只 ...
- 好用到爆的Python自动化办公教程,Python × Excel × Word × PPT 一次解决
好用到爆的Python自动化办公教程,Python × Excel × Word × PPT 一次解决 大家好,我是黄伟
- python编程案例教程答案-python编程案例教程pdf下载
python编程案例教程pdf下载内容摘要 python编程案例教程pdf下载教程,巧妙的谋划,巧妙的计谋.娄底电脑教程,巧克力奶茶等都是理想的增肥品.巧克力麦片等等,南宁街舞教程,巧克力成为一种&q ...
- python新手入门教程思路-Python新手入门教程_教你怎么用Python做数据分析
Python新手入门教程_教你怎么用Python做数据分析 跟大家讲了这么多期的Python教程,有小伙伴在学Python新手教程的时候说学Python比较复杂的地方就是资料太多了,比较复杂.很多网上 ...
- word2vec python实现_教程 | 在Python和TensorFlow上构建Word2Vec词嵌入模型
原标题:教程 | 在Python和TensorFlow上构建Word2Vec词嵌入模型 选自adventuresinmachinelearning 参与:李诗萌.刘晓坤 本文详细介绍了 word2ve ...
- python爬取图片教程-推荐|Python 爬虫系列教程一爬取批量百度图片
Python 爬虫系列教程一爬取批量百度图片https://blog.csdn.net/qq_40774175/article/details/81273198# -*- coding: utf-8 ...
- python处理excel教程实例-python如何处理excel数据
python处理excel数据的方法:1.使用xlrd来处理:2.使用[xlutils+xlrd]来处理:3.使用xlwt来处理:4.使用pyExcelerator来处理:5.使用Pandas库来处理 ...
- python程序设计实践教程答案-Python程序设计实践教程
书名:Python程序设计实践教程 定价:29.8 ISBN:9787115532602 作者:储岳中 薛希玲 版次:*1版 出版时间:2020-04 内容提要: 本书是Python语言程序设计的配套 ...
最新文章
- python提取数据包中的文件_Python-对Pcap文件进行处理,获取指定TCP流
- 把hive数据导出至mysql
- flume 中的 hdfs sink round 和roll
- crontab 每周五_crontab定时任务 每隔一周的周五执行
- ubuntu 自动挂载工具_Ubuntu设置开机自动挂载所有格式硬盘分区
- Maven私服(二) - Nexus的安装
- vue滚动条禁止_vue.js中实现禁止浏览器滚动方法
- pytorch中获取模型参数
- Linux 网络抓包
- 按键精灵脚本与Total Control手机群控系统的完美结合
- 360极速浏览器、360浏览器如何清除缓存、清除历史记录、清除cookies
- Bzoj3236:[Ahoi2013]作业:莫队算法+树状数组
- 怎么把PDF翻译成中文?教你便捷翻译方法
- 网易2017春招[编程题]赶去公司@Java
- [Python]经典例题——解一元二次方程
- 第4章 数据的概括性度量
- Mysql 1146错误 出现Table 'mysql.proc' doesn't exist ( 1146 )
- 频率色散参数和相关时间
- 商品交易系统之---产品介绍
- 一看就会,12种不同场景的拍摄模式!