turtle

Posted 猪精雅0

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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()

输出

 

以上是关于turtle的主要内容,如果未能解决你的问题,请参考以下文章

利用turtle库绘制半径为80的圆,要求画笔颜色为绿色,画笔宽度为3,填充黄色,代码?

Python-100天代码

turtle库的几个案例进阶,代码可直接运行(python经典编程案例)

turtle库的几个案例进阶,代码可直接运行(python经典编程案例)

Python科赫雪花代码

python3 turtle使用报错,代码没有对齐