python 利用turtle库绘制笑脸和哭脸的例子

所属分类: 脚本专栏 / python 阅读数: 128
收藏 0 赞 0 分享

我就废话不多说了,直接上代码吧!

import turtle
turtle.pensize(5)
turtle.pencolor("yellow")
turtle.fillcolor("red")
turtle.penup()
turtle.goto(0,-200)
turtle.pendown()
turtle.circle(200)
 
turtle.penup()
turtle.goto(-100,50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(17.5)
turtle.end_fill()
 
turtle.penup()
turtle.goto(100,50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(17.5)
turtle.end_fill()
 
turtle.penup()
turtle.goto(0,50)
turtle.pendown()
turtle.circle(-70,steps=3)
 
turtle.penup()
turtle.goto(-100,-70)
turtle.pendown()
turtle.right(90)
turtle.circle(100,180)
turtle.mainloop()#结果如下

import turtle
turtle.pensize(5)
turtle.pencolor("green")
turtle.fillcolor("red")
turtle.penup()
turtle.goto(0,-200)
turtle.pendown()
turtle.circle(200)
 
turtle.penup()
turtle.goto(-100,50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(17.5)
turtle.end_fill()
 
turtle.penup()
turtle.goto(100,50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(17.5)
turtle.end_fill()
 
turtle.penup()
turtle.goto(0,50)
turtle.pendown()
turtle.circle(-70,steps=3)
 
turtle.penup()
turtle.goto(-50,-120)
turtle.pendown()
turtle.left(90)
turtle.circle(-50,180)
 
turtle.mainloop()#结果如下

import turtle
turtle.pensize(5)
turtle.pencolor("green")
turtle.fillcolor("red")
turtle.penup()
turtle.goto(0,-200)
turtle.pendown()
turtle.circle(200)
 
turtle.penup()
turtle.goto(-100,50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(17.5)
turtle.end_fill()
 
turtle.penup()
turtle.goto(100,50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(17.5)
turtle.end_fill()
 
turtle.penup()
turtle.goto(0,50)
turtle.pendown()
turtle.circle(-70,steps=3)
 
turtle.penup()
 
turtle.goto(-100,-120)
turtle.pendown()
 
turtle.left(90)
turtle.circle(-25,180)
 
turtle.left(180)
turtle.circle(-25,180)
 
turtle.left(180)
turtle.circle(-25,180)
 
turtle.left(180)
turtle.circle(-25,180)
 
turtle.mainloop()#结果如下

以上这篇python 利用turtle库绘制笑脸和哭脸的例子就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

更多精彩内容其他人还在看

深入浅析python3中的unicode和bytes问题

在python3中,有两种字符串类型,默认的就是str,即unicode,也叫做文本类型。这篇文章主要介绍了python3中的unicode和bytes问题,需要的朋友可以参考下
收藏 0 赞 0 分享

python3 自动识别usb连接状态,即对usb重连的判断方法

今天小编就为大家分享一篇python3 自动识别usb连接状态,即对usb重连的判断方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
收藏 0 赞 0 分享

python二进制文件的转译详解

这篇文章主要介绍了python二进制文件的转译详解的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
收藏 0 赞 0 分享

python字符串中匹配数字的正则表达式

正则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配。这篇文章主要介绍了python字符串中匹配数字的正则表达式 ,需要的朋友可以参考下
收藏 0 赞 0 分享

在Python中COM口的调用方法

今天小编就为大家分享一篇在Python中COM口的调用方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
收藏 0 赞 0 分享

Python read函数按字节(字符)读取文件的实现

这篇文章主要介绍了Python read函数按字节(字符)读取文件的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

python读取图片的方式,以及将图片以三维数组的形式输出方法

今天小编就为大家分享一篇python读取图片的方式,以及将图片以三维数组的形式输出方法,具有好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
收藏 0 赞 0 分享

在python中利用numpy求解多项式以及多项式拟合的方法

今天小编就为大家分享一篇在python中利用numpy求解多项式以及多项式拟合的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
收藏 0 赞 0 分享

Python正则表达式匹配数字和小数的方法

这篇文章主要介绍了Python正则匹配数字和小数的方法,本文通过示例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享

python读写配置文件操作示例

这篇文章主要介绍了python读写配置文件操作,结合实例形式分析了Python针对ini配置文件的读取、解析、写入等相关操作技巧,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多