海龟绘图turtle库之二级基础编程题
一、画一个太极图

import turtle as t
t.pensize(2)#设置笔画宽度
t.circle(100)#以100为半径的圆
t.circle(50, 180)
t.circle(-50, 180)
t.penup()#抬起画笔
t.goto(0, 40)#移动到绝对位置
t.pendown()#放下画笔
t.circle(10)
t.penup()
t.goto(0, 140)
t.pendown()
t.circle(10)
t.hideturtle()#隐藏画笔
t.done()
二、画一个同心圆

import turtle as t
def drawcircle(n):
t.pensize(3)
t.penup()
t.goto(0, -n)
t.pendown()
t.circle(n)
for i in range(20,80,20):
drawcircle(i)
t.hideturtle()
t.done()
三、画一个同心切

import turtle as t
for i in range(20,80,20):
t.circle(i)
四、画一个五角星

import turtle as t
t.color('red', 'red')
t.begin_fill()
for i in range(5):
t.fd(200)
t.rt(144)
t.hideturtle()
t.end_fill()
t.done()
六、画一个花瓣

import turtle as t
t.penup()
t.goto(-40,-90)
t.pendown()
t.colormode(255)
t.screensize(800,600,'white')
t.pensize(2)
t.color((255,155,192),(144,218,253))
t.begin_fill()
for i in range(4):
t.seth(90*(i+1))
t.rt(45)
t.circle(150, 90)
t.seth(-90 + i * 90
t.circle(150, 90)
t.end_fill()
t.done()
七、画一个菱形(要求根据题意使用适当函数)

import turtle as t
t.rt(30)
for i in range(2):
t.color('red')
t.fd(100)
t.rt(-60*(i+1))
for j in range(2):
t.fd(100)
t.rt(-60*(j+1))
t.hideturtle()
t.done()#使用rt函数
八、画一个多彩圆

import turtle
colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'purple']
for i in range(7):
c = colors[i]
turtle.color(c, c)
turtle.begin_fill()
turtle.lt(360/7)
turtle.circle(50)
turtle.end_fill()
turtle.done()
九、后续未完...
一、佩奇(课外...)

import turtle as t
t.pensize(4)
t.colormode(255) #取色范围
t.color((255,155,192),"pink")
t.setup(840,500)
t.speed(3) #时速
t.pu()
t.goto(-100,100) #绝对位置
t.pd()
t.seth(-30)
t.begin_fill()
a=0.4
for i in range(120):
if 0<=i<30 or 60<=i<90:
a=a+0.08
t.lt(3)
t.fd(a)
else:
a=a-0.08
t.lt(3)
t.fd(a)
t.end_fill()
t.pu()
t.seth(90)
t.fd(25)
t.seth(0)
t.fd(10)
t.pd()
t.pencolor(255,155,192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160,82,45)
t.end_fill()
t.pu()
t.seth(0)
t.fd(20)
t.pd()
t.pencolor(255,155,192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160,82,45)
t.end_fill() #头
t.color((255,155,192),"pink")
t.pu()
t.seth(90)
t.fd(41)
t.seth(0)
t.fd(0)
t.pd()
t.begin_fill()
t.seth(180)
t.circle(300,-30)
t.circle(100,-60)
t.circle(80,-100)
t.circle(150,-20)
t.circle(60,-95)
t.seth(161)
t.circle(-300,15)
t.pu()
# t.goto(-100,100)
t.goto(-100, 100)
t.pd()
t.seth(-30)
a=0.4
for i in range(60):
if 0<=i<30 or 60<=i<90:
a=a+0.08
t.lt(3)
t.fd(a)
else:
a=a-0.08
t.lt(3)
t.fd(a)
t.end_fill()
t.color((255,155,192),"pink")
t.pu()
t.seth(90)
t.fd(-7)
t.seth(0)
t.fd(70)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50,50)
t.circle(-10,120)
t.circle(-50,54)
t.end_fill()
t.pu()
t.seth(90)
t.fd(-12)
t.seth(0)
t.fd(30)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50,50)
t.circle(-10,120)
t.circle(-50,56)
t.end_fill() #眼睛
t.color((255,155,192),"white")
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-95)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
t.color((255,155,192),"white")
t.pu()
t.seth(90)
t.fd(-25)
t.seth(0)
t.fd(40)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill() #腮
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(-95)
t.seth(0)
t.fd(65)
t.pd()
t.begin_fill()
t.circle(30)
t.end_fill() #嘴
t.color(239,69,19)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(-100)
t.pd()
t.seth(-80)
t.circle(30,40)
t.circle(40,80) #身体
t.color("red",(255,99,71))
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-78)
t.pd()
t.begin_fill()
t.seth(-130)
t.circle(100,10)
t.circle(300,30)
t.seth(0)
t.fd(230)
t.seth(90)
t.circle(300,30)
t.circle(100,3)
t.color((255,155,192),(255,100,100))
t.seth(-135)
t.circle(-80,63)
t.circle(-150,24)
t.end_fill() #手
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(-40)
t.seth(0)
t.fd(-27)
t.pd()
t.seth(-160)
t.circle(300,15)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-10)
t.circle(-20,90)
t.pu()
t.seth(90)
t.fd(30)
t.seth(0)
t.fd(237)
t.pd()
t.seth(-20)
t.circle(-300,15)
t.pu()
t.seth(90)
t.fd(20)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-170)
t.circle(20,90) #脚
t.pensize(10)
t.color((240,128,128))
t.pu()
t.seth(90)
t.fd(-75)
t.seth(0)
t.fd(-180)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)
t.pensize(10)
t.color((240,128,128))
t.pu()#penup提笔
t.seth(90)
t.fd(40)
t.seth(0)
t.fd(90)#=forward
t.pd()#=pendown
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20) #尾巴
t.pensize(4)
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(70)
t.seth(0)
t.fd(95)
t.pd()
t.seth(0)
t.circle(70,20)
t.circle(10,330)
t.circle(70,30)
t.hideturtle()
t.done()
海龟绘图turtle库之二级基础编程题的更多相关文章
- Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 3. 循环
在前面的教程中,咪博士留了一道练习题给大家—-画正方形,相信聪明的你应该已经画出来了. 下面是咪博士实现的代码. 是不是跟你的代码很像呢? import turtle turtle.forward(2 ...
- Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 7. 条件循环
条件循环能够让程序在条件成立时(即为真时)重复执行循环体中的语句.如果条件一直成立(即永远不会为假),则循环会一直进行下去,不会停止.如果初始时,条件不成立,则循环 1 次也不会执行.Python 中 ...
- Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 6. 条件
前面的教程中,我们已经可以让小海龟绘制出各种图形了.但是,所有绘图的代码都是预先编好的,程序一旦运行起来,运行结果(绘制的图形)就是固定不变的.这一节中,咪博士将教大家如何让海龟响应用户的输入. im ...
- Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 5. 参数
上一个教程中,咪博士带大家学习了函数的使用.例如,line_without_moving 函数,可以让海龟先画出一条线段,然后再回来起点. def line_without_moving(): tur ...
- Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 4. 函数
什么样的程序员才是优秀的程序员?咪博士认为“慵懒”的程序员才是真正优秀的程序员.听起来不合逻辑?真正优秀的程序员知道如何高效地工作,而不是用不止境的加班来完成工作任务.函数便是程序员高效工作的利器之一 ...
- Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 2. 变量
大家在中学就已经学过变量的概念了.例如:我们令 x = 100,则可以推出 x*2 = 200 试试下面这段 Python 代码 import turtle turtle.shape("tu ...
- Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 1. 神秘朋友
Python (Windows 下) 自带了一个非常有趣的 海龟绘图程序 (turtle),它是本系列课程的主角. 在 PyCharm 中,新建一个项目,然后在代码编辑器中输入 import turt ...
- Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 0. 准备工作
一.关于 Python Python 是全球使用人数增长最快的编程语言!它易于入门.功能强大,从 Web 后端 到 数据分析.人工智能,到处都能看到 Python 的身影. Python 有两个主要的 ...
- 海龟绘图turtle模块的使用
在本章中,我们将编写简短的.简单的程序来创建漂亮的.复杂的视觉效果.为了做到这一点,我们可以使用海龟作图软件.在海龟作图中,我们可以编写指令让一个虚拟的(想象中的)海龟在屏幕上来回移动.这个海龟带着一 ...
随机推荐
- validate表单验证
validate使用步骤:1.导入jquery.js2.导入validate.js3.在页面加载成功之后 对表单进行校验 $("选择器").validate()4.在valida ...
- mysqli链接数据库
<?php $uid = $_GET['uid']; $host = 'localhost';$database = 'test';$username = 'root';$password = ...
- CS通用项目系统搭建——三层架构第二天 (补一篇完整的SqlHelper)
#region ExecuteNonQuery(如果是增,删,修) /// <summary> /// 执行sql命令 /// </summary> /// <param ...
- 第二周博客作业 <西北师范大学| 周安伟>
一,本周助教小结 逐步开始适应助教工作,对学生发布的博客进行点评,查看学生对软件工程前期的准备情况. 二,助教本人博客 https://home.cnblogs.com/u/zaw-315/ 三,学生 ...
- leedcode算法解题思路
1.两数之和 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标. 你可以假设每种输入只会对应一个答案.但是,你不能重复利用这个 ...
- spring :Log4j各级别日志重复打印
使用filter进行日志过滤 这个其实是Log4j自带的方案,也是推荐方案,不知道为什么网上的资料却很少提到这点. 把log4j.properties配置文件修改成如下: #root日志 log4j. ...
- Python模拟接口登录
参考地址:https://blog.csdn.net/rifengxxc/article/details/77414090 下面讲下关于python模拟登录实验,之前怎么调试也不行,我也是摸索了好久, ...
- 3D 数据
1.3D 图 首先在进行 3D Plot 时除了导入 matplotlib ,还要额外添加一个模块,即 Axes 3D 3D 坐标轴显示: import numpy as np import matp ...
- 20172306 2018-2019-2 《Java程序设计与数据结构》第七周学习总结
20172306 2018-2019-2 <Java程序设计与数据结构>第七周学习总结 教材学习内容总结 概述 二叉查找树是一种含有附加属性的二叉树,即其左孩子小于父结点,而父结点又小于或 ...
- [精华][推荐] CAS SSO单点登录环境搭建及实例
1.因为是本地模拟sso环境,而sso的环境测试需要域名,所以需要虚拟几个域名出来,步骤如下: 2.进入目录C:\Windows\System32\drivers\etc 3.修改hosts文件 12 ...