turtle

画一组同切圆

输入

import turtle

turtle.color(‘red‘)
turtle.circle(30)
turtle.circle(60)
turtle.circle(90)
turtle.circle(120)
turtle.circle(150)
turtle.circle(180)
turtle.hideturtle()

输出

画一组同心圆

输入

import turtle

turtle.pos()

turtle.color(‘red‘)
turtle.begin_fill()
turtle.up()
turtle.goto(0,-10)
turtle.down()
turtle.circle(10)

turtle.color(‘orange‘)
turtle.up()
turtle.goto(0,-30)
turtle.down()
turtle.circle(30)

turtle.color(‘yellow‘)
turtle.up()
turtle.goto(0,-60)
turtle.down()
turtle.circle(60)

turtle.color(‘green‘)
turtle.up()
turtle.goto(0,-90)
turtle.down()
turtle.circle(90)

turtle.color(‘blue‘)
turtle.up()
turtle.goto(0,-120)
turtle.down()
turtle.circle(120)

turtle.color(‘purple‘)
turtle.up()
turtle.goto(0,-150)
turtle.down()
turtle.circle(150)

turtle.color(‘pink‘)
turtle.up()
turtle.goto(0,-180)
turtle.down()
turtle.circle(180)

输出

画一个五角星

输入

import turtle

turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.hideturtle()

输出

画一个黄色实心五角星

输入

import turtle
turtle.color(‘yellow‘)
turtle.fillcolor(‘yellow‘)
turtle.begin_fill()
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
turtle.hideturtle()

输出

画左上角的五颗五角星

import turtle

turtle.bgcolor(‘red‘)
turtle.speed(100)
turtle.pos()
turtle.up()
turtle.goto(-400,200)
turtle.color(‘yellow‘)
turtle.fillcolor(‘yellow‘)
turtle.begin_fill()
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
turtle.down()

turtle.up()
turtle.goto(-270,320)
turtle.color(‘yellow‘)
turtle.fillcolor(‘yellow‘)
turtle.begin_fill()
turtle.right(45)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
turtle.down()

turtle.up()
turtle.goto(-200,210)
turtle.color(‘yellow‘)
turtle.fillcolor(‘yellow‘)
turtle.begin_fill()
turtle.right(160)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
turtle.down()

turtle.up()
turtle.goto(-190,130)
turtle.color(‘yellow‘)
turtle.fillcolor(‘yellow‘)
turtle.begin_fill()
turtle.left(0)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
turtle.down()

turtle.up()
turtle.goto(-250,60)
turtle.color(‘yellow‘)
turtle.fillcolor(‘yellow‘)
turtle.begin_fill()
turtle.right(20)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
turtle.down()

turtle.hideturtle()

输出

时间: 2024-11-10 15:30:32

turtle的相关文章

turtle库基础练习

1.画一组同切圆 import turtle turtle.shape('turtle') turtle.circle(20) turtle.circle(40) turtle.circle(60) turtle.circle(80) 2.画一组同心圆 import turtle turtle.shape('turtle') turtle.pos() (0.00,0.00) turtle.circle(20) turtle.up() turtle.goto(0,-20) turtle.down(

【python】用turtle库画一棵树

# drawtree.py from turtle import Turtle, mainloop def tree(plist, l, a, f): """ plist is list of pens l is length of branch a is half of the angle between 2 branches f is factor by which branch is shortened from level to level.""&

用Python的Turtle模块绘制五星红旗

Edit 用Python的Turtle模块绘制五星红旗 在Udacity上课时学到了python的turtle方法,这是一个很经典的用来教小孩儿编程的图形模块,最早起源于logo语言.python本身内置了这个模块,其可视化的方法可以帮助小孩儿对编程的一些基本理念有所理解. 在作业提交的论坛里看到很多turtle画出来的精美图形,想不出什么要画的东西,于是决定拿五星红旗来练练手. 前期准备 五星红旗绘制参数 Turtle官方文档 turtle的基本操作 # 初始化屏幕 window = turt

turtle库练习

1.画一组同切圆 >>> import turtle >>> turtle.circle(50) >>> turtle.circle(80)>>> turtle.circle(100)>>> turtle.circle(60)>>> turtle.circle(70)>>> turtle.circle(90) 2.画一组同心圆 >>> import turtle

Python输入输出练习,运算练习,turtle初步练习

print('Hello World!') name=input('输入姓名') print('%s同学,你好'%name) print('和=',int(input('数字a='))+int(input('数字b='))) 三角新面积a=input('三角形的边a=') b=input('三角形的边b=') c=input('三角形的边c=') p=(float(a)+float(b)+float(c))/2 s=(float(p)*(float(p)-float(a))*(float(p)-

Python turtle库的应用——蛇

turtle库介绍 1.Turtle中的turtle.setup()函数用于启动一个图形窗口,它有四个参数 turtle.setup(width, height, startx, starty) 分别是:启动窗口的宽度和高度表示窗口启动时,窗口左上角在屏幕中的坐标位置. 我们所使用的显示屏幕也是一个坐标系,该坐标系以左上角为原点,向左和向下分别是x轴和y轴.蟒蛇程序代码启动一个1300像素宽.800像素高的窗口,该窗口的左上角是屏幕的左上角. (startx,starty)表示画的初始点,(0,

python的turtle模块画折线图

代码如下: import turtle yValues = [10.0,7.4,6.4,5.3,4.4,3.7,2.6] def main(): t = turtle.Turtle() t.hideturtle() drawLine(t,0,0,300,0) #画x轴 drawLine(t,0,0,0,175) #画y轴 #画折线 for i in range(6): drawLineWithDots(t,40 + (40 * i),15 * yValues[i],40 + (40 * (i+1

关于报错:AttributeError: module 'turtle' has no attribute 'setup' 问题

对于我们菜鸟,往往安装软件后,都容易使用默认设置,结果将写的文件保存到了安装目录下. 这样造成了很大得隐患,如果写得文件,名称与安装目录下得系统文件名称重复,就容易出现以上报错. 解决方法:1.将文件名称修改为与安装目录下得系统文件名称不冲突. 2.最好直接将自己得文件保存路径修改为其他地方,不要与安装目录重复. 关于报错:AttributeError: module 'turtle' has no attribute 'setup' 问题

使用Python的turtle(海龟)模块画图

使用Python的turtle(海龟)模块画图 第一步:让Python引入turtle模块,引入模块就是告诉Python你想要用它. import turtle 第二步:创建画布.调用turtle中的Pen函数. t = turtle.Pen() 第三步:移动海龟. t.forward(50) forward的中文意思是"向前地:促进".所以这行代码的意思是海龟向前移动50个像素: t.left(90) 让海龟左转90度 现在我们可以尝试画一个方块,思路就是前进-转向90度-前进,循环

turtle模块实现多边形

import turtle def square(length,n):#边长和边数 bob = turtle.Turtle() for i in range(n): bob.fd(length) bob.lt(360/n)#每次所转角度 turtle.mainloop() square(70,6) <a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=14810f366fd210392f3943e7a1f03d