使用Python画出小人发射爱心的代码
2019-12-08 07:09
7811 查看
我就废话不多说了,直接上代码吧!
#2.14 from turtle import * from time import sleep def go_to(x, y): up() goto(x, y) down() def head(x,y,r): go_to(x,y) speed(1) circle(r) leg(x,y) def leg(x,y): right(90) forward(180) right(30) forward(100) left(120) go_to(x,y-180) forward(100) right(120) forward(100) left(120) hand(x,y) def hand(x,y): go_to(x,y-60) forward(100) left(60) forward(100) go_to(x, y - 90) right(60) forward(100) right(60) forward(100) left(60) eye(x,y) def eye(x,y): go_to(x-50,y+130) right(90) forward(50) go_to(x+40,y+130) forward(50) left(90) def big_Circle(size): speed(20) for i in range(150): forward(size) right(0.3) def line(size): speed(1) forward(51*size) def small_Circle(size): speed(10) for i in range(210): forward(size) right(0.786) def heart(x, y, size): go_to(x, y) left(150) begin_fill() line(size) big_Circle(size) small_Circle(size) left(120) small_Circle(size) big_Circle(size) line(size) end_fill() def main(): pensize(2) color('red', 'pink') head(-120, 100, 100) heart(250, -80, 1) go_to(200, -300) write("To: 智慧与美貌并存的", move=True, align="left", font=("楷体", 20, "normal")) done() main()
运行结果:
以上这篇使用Python画出小人发射爱心的代码就是小编分享给大家的全部内容了,希望能给大家一个参考
您可能感兴趣的文章:
相关文章推荐
- 使用ropemacs对python代码进行补全
- 【备忘】使用FME PythonCaller的基本代码结构
- 使用python的列表解析以及函数式计算来简化代码
- C Java PHP Perl Python的程序代码美化工具使用
- Python使用Socket(Https)Post登录百度的实现代码
- 如何使用 Pylint 来规范 Python 代码风格
- 使用 Python 获取 Linux 系统信息的代码
- (转载)C Java PHP Perl Python的程序代码美化工具使用
- 使用VC内嵌Python实现的一个代码检测工具
- Python使用Thrift的代码分析
- 使用2to3将代码移植到Python 3
- 使用SonarQube+Eclipse来分析python代码
- selenium+python关于登录的脚本代码,使用了读取excel以及向excel中写入测试结果的方法
- Python练习代码 -- 单元测试 使用unittest
- Python使用百度API上传文件到百度网盘代码分享
- 使用Python进行AES加密和解密的示例代码
- 使用Python清理工程目录,方便代码备份
- 使用 stackato 发布 python-tornado 代码
- 使用cf.SyntaxHighighter作为Windows Live Writer 2011的插件发布Python代码到博客园
- python client使用http post 到server端的代码