(turtle基础)一条小蛇

#我做了一条简单的小蟒蛇
from turtle import *
setup(650,350,200,200)
pu()
fd(-250)
pd()
pensize(25)
pencolor('red')
seth(-40)
for i in range(4):circle(40,80)pencolor('blue')circle(-40,80)pencolor('purple')
circle(40,80/2)
fd(40)
pencolor('red')
circle(16,180)
fd(40*2/3)

(turtle基础)一颗小星星

#我做了一颗简单的小星星
from turtle import *
fillcolor('red')
begin_fill()
while True:fd(200)right(144)if abs(pos())<1:break;
end_fill()
hideturtle()

# coding=utf-8
import turtle
import timeturtle.pensize(5)
turtle.pencolor("yellow")
turtle.fillcolor("red")turtle.begin_fill()
for _ in range(5):turtle.forward(200)turtle.right(144)
turtle.end_fill()
time.sleep(2)turtle.penup()
turtle.goto(-150,-120)
turtle.color("violet")
turtle.write("Done", font=('Arial', 40, 'normal'))turtle.mainloop()

(turtle基础)一朵太阳花

#我做了一朵太阳花
from turtle import *
color('red','yellow')
begin_fill()
while True:fd(200)left(170)if abs(pos())<1:break;
end_fill()
hideturtle()

或者

# coding=utf-8
import turtle
import time# 同时设置pencolor=color1, fillcolor=color2
turtle.color("red", "yellow")turtle.begin_fill()
for _ in range(50):
turtle.forward(200)
turtle.left(170)
turtle.end_fill()turtle.mainloop()

(turtle基础进阶)一个小时钟

# coding=utf-8import turtle
from datetime import *# 抬起画笔,向前运动一段距离放下
def Skip(step):turtle.penup()turtle.forward(step)turtle.pendown()def mkHand(name, length):# 注册Turtle形状,建立表针Turtleturtle.reset()Skip(-length * 0.1)# 开始记录多边形的顶点。当前的乌龟位置是多边形的第一个顶点。turtle.begin_poly()turtle.forward(length * 1.1)# 停止记录多边形的顶点。当前的乌龟位置是多边形的最后一个顶点。将与第一个顶点相连。turtle.end_poly()# 返回最后记录的多边形。handForm = turtle.get_poly()turtle.register_shape(name, handForm)def Init():global secHand, minHand, hurHand, printer# 重置Turtle指向北turtle.mode("logo")# 建立三个表针Turtle并初始化mkHand("secHand", 135)mkHand("minHand", 125)mkHand("hurHand", 90)secHand = turtle.Turtle()secHand.shape("secHand")minHand = turtle.Turtle()minHand.shape("minHand")hurHand = turtle.Turtle()hurHand.shape("hurHand")for hand in secHand, minHand, hurHand:hand.shapesize(1, 1, 3)hand.speed(0)# 建立输出文字Turtleprinter = turtle.Turtle()# 隐藏画笔的turtle形状printer.hideturtle()printer.penup()def SetupClock(radius):# 建立表的外框turtle.reset()turtle.pensize(7)for i in range(60):Skip(radius)if i % 5 == 0:turtle.forward(20)Skip(-radius - 20)Skip(radius + 20)if i == 0:turtle.write(int(12), align="center", font=("Courier", 14, "bold"))elif i == 30:Skip(25)turtle.write(int(i/5), align="center", font=("Courier", 14, "bold"))Skip(-25)elif (i == 25 or i == 35):Skip(20)turtle.write(int(i/5), align="center", font=("Courier", 14, "bold"))Skip(-20)else:turtle.write(int(i/5), align="center", font=("Courier", 14, "bold"))Skip(-radius - 20)else:turtle.dot(5)Skip(-radius)turtle.right(6)def Week(t):  week = ["星期一", "星期二", "星期三","星期四", "星期五", "星期六", "星期日"]return week[t.weekday()]def Date(t):y = t.yearm = t.monthd = t.dayreturn "%s %d%d" % (y, m, d)def Tick():# 绘制表针的动态显示t = datetime.today()second = t.second + t.microsecond * 0.000001minute = t.minute + second / 60.0hour = t.hour + minute / 60.0secHand.setheading(6 * second)minHand.setheading(6 * minute)hurHand.setheading(30 * hour)turtle.tracer(False)printer.forward(65)printer.write(Week(t), align="center",font=("Courier", 14, "bold"))printer.back(130)printer.write(Date(t), align="center",font=("Courier", 14, "bold"))printer.home()turtle.tracer(True)# 100ms后继续调用tickturtle.ontimer(Tick, 100)def main():# 打开/关闭龟动画,并为更新图纸设置延迟。turtle.tracer(False)Init()SetupClock(160)turtle.tracer(True)Tick()turtle.mainloop()if __name__ == "__main__":main()

(turtle基础进阶)一个小魔幻场景

from turtle import *
pensize(2)
bgcolor("black")
colors=["red","blue","yellow","purple"]
speed(10)for x in range(400):fd(2*x)color(colors[x%4])left(92)
hideturtle()
done()

(turtle基础进阶)一个告白的心

from turtle import*
setup(750,500)
penup()
pensize(25)
pencolor("pink")
fd(-230)
seth(90)
pendown()
circle(-50,180)
circle(50,-180)
circle(75,-50)
circle(-190,-45)
penup()
fd(185)
seth(180)
fd(120)
seth(90)
pendown()
circle(-75,-50)
circle(190,-45)
penup()
fd(184)
seth(0)
fd(80)
seth(90)
pendown()
circle(-50,180)
circle(50,-180)
circle(75,-50)
circle(-190,-45)
penup()
fd(185)
seth(180)
fd(120)
seth(90)
pendown()
circle(-75,-50)
circle(190,-45)
penup()
fd(150)
seth(180)
fd(300)
pencolor("red")
pensize(10)
pendown()
fd(-500)
seth(90)
fd(30)
fd(-60)
seth(30)
fd(60)
seth(150)
fd(60)
done()


转载来源


from turtle import *
#黄色爱心铃铛
pensize(5)
seth(0)
color('orange')
begin_fill()
lt(135)
fd(22)
right(180)#画笔掉头
circle(8,-180)backward(8)
right(90)
forward(8)
circle(-8,180)
fd(22)end_fill()
hideturtle()

原文链接

python程序设计基础之turtle库制作简单的小图片相关推荐

  1. turtle库制作简单动画和总结

    turtle制作简单动画和总结 最后制作的效果图 制作的代码,写的比较乱,后面还有皮卡丘动画,有需要可以私我. def tree(n,l):pd()#下笔#阴影效果t = cos(radians(he ...

  2. python的turtle怎么画曲线_利用 turtle库绘制简单图形

    turtle库是python的基础绘图库,这个库被介绍为一个最常用的用来介绍编程知识的方法库,其主要是用于程序设计入门,是标准库之一,利用turtle可以制作很多复杂的绘图. turtle名称含义为& ...

  3. python打折简单程序每满_丰满Python程序设计基础【实境编程】_高校邦_答案

    丰满Python程序设计基础[实境编程]_高校邦_答案h779 丰满Python程序设计基础[实境编程]_高校邦_答案 关注公众号{帅搜}即可查询答案 支持:大学网课,智慧树,知到,超星,尔雅,学习通 ...

  4. python基本原理概论_优学院《2020年马克思主义基本原理概论题库(高职类)》查题教程2020高校邦《Python程序设计基础【实境编程】》答案完整...

    优学院<2020年马克思主义基本原理概论题库(高职类)>查题教程2020高校邦<Python程序设计基础[实境编程]>答案完整 更多相关问题 专业职业是相对以下哪点而言的(). ...

  5. python中的turtle如何运行_python中turtle库的简单使用教程

    python的turtle库的简单使用 Python的turtle库是一个直观有趣的图形绘制函数库,是python的标准库之一. 一.绘图坐标体系 turtle库绘制图形的基本框架:通过一个小海龟在坐 ...

  6. Python之Turtle库绘制简单图形

    Python之Turtle库绘制简单图形 来绘制正方形.三角形.五边形.五角形 import turtle #引入turtle库pen=turtle.Turtle() #创建turtle类型的画笔 # ...

  7. 用turtle库制作一个简单的小游戏《鸡子大战篮球》

    刚上大学,学习python不到两月半,连简单的字典.元组数据类型都还没有捂熟.这不刚好python小组作业是用turtle库画自己喜欢的图案吗,在我们小组的努力下我们画好了5只小只因,于是我就大胆的进 ...

  8. python的turtle库的简单使用

    python的turtle库的简单使用 Python的turtle库是一个直观有趣的图形绘制函数库,是python的标准库之一. 一.绘图坐标体系 turtle库绘制图形的基本框架:通过一个小海龟在坐 ...

  9. Python标准库:turtle库的简单快速入门

    在计算机二级Python的计算生态(其实也就是库)考察中,可以分为两大类:标准库和第三方库. 而标准库中明确要求掌握的就是turtle库和random库,第三方库大都是掌握其在各个常用领域的一些主流库 ...

最新文章

  1. 拼多多二面:Mybatis是如何执行一条SQL命令的?
  2. python第三方库安装方法-Python第三方库安装
  3. 新秀nginx源代码分析数据结构篇(四)红黑树ngx_rbtree_t
  4. netty socket超时设置_Netty 学习和进阶策略
  5. 数据库设计笔记——关系型数据库基础知识(三)
  6. 网上linux实验平台,Linux操作系统实验教程
  7. Spark Structured SQL : JDBC写入Oracle
  8. C++ 枚举类型的思考
  9. MySQL 处理海量数据时一些优化查询速度方法
  10. 《Visual Studio Code权威指南》读后总结
  11. 平板计算机触摸屏失灵修复小技巧,触摸屏失灵有哪些修复小技巧?
  12. μc/os-II原理简介(笔记)
  13. Java实现顺序表的创建及基本操作(增删改查)
  14. 前端新技术(离线缓存、CDN内容分发网络)
  15. Sam Altman 山姆奥特曼:强化学习进展 Reinforcement Learning Progress
  16. java上传文件夹到oss
  17. 适用于各浏览器支持图片预览,无刷新异步批量上传js插件(2)
  18. C语言程序设计卢萍,卢萍
  19. 万字详解整个数据仓库设计体系
  20. word文档标注参考文献以及标注参考文献出现的直线问题的解决

热门文章

  1. SQL SERVER数据库误删除误格式化误重装软件覆盖数据恢复修复
  2. Mysql免安装版下载以及配置
  3. 如何找到win10系统当前使用的壁纸位置
  4. ckeditor4 自定义组件之文字格式组件,类加粗,类下划线(vue项目)
  5. BOM制作系列之一:BOM拆分
  6. 手机按键精灵学习 —— 基础知识
  7. vue2实现高德地图 JSAPI 2.0可拖拽的路线规划(DragRoute)组件实现对每个经过点设置不同的经过点名称
  8. oracle脏读如何解决,关于脏读分析
  9. 史上最全的FreeIPA搭建教程(二)
  10. 【文件上传漏洞11】中间件文件解析漏洞基础知识及实验——Nginx