Turtle入门(实例)

简介: Turtle入门(实例)

实例一:

import turtle
turtle.speed("fastest")
turtle.pensize(1)
color=["red","yellow","blue","green"]
for y in  range(250):
    turtle.pencolor(color[y%4])
    turtle.forward(3*y)
    turtle.right(29)
    turtle.left(175)

效果图:

1.png

实例二

import turtle
t = turtle.Pen()
t.speed( 0 )
turtle.bgcolor( "black" )
colors = [ "red","orange","yellow","green","blue","purple","pink" ]
sides = int( turtle.numinput( "边数","请输入图形边数,1 到 8 之间:",4,1,8 ) )
your_name = turtle.textinput( "名字","请输入你的名字:" )
for x in range( 0,200):
    t.pencolor( colors[x%sides] )
    t.penup()
    t.forward( x*3/sides + x )
    t.pendown()
    t.write( your_name,font=( "宋体",int( (x+4)/4 ),"bold" ) )
    t.left( 360/sides + 1 )
    t.width( x*sides / 200 )

效果图:

1.png

1.png

相关文章
|
Python
turtle库的使用(专题)
turtle库的使用(专题)
434 0
turtle库的使用(专题)
|
10月前
|
Python
绘制一个时钟(python-turtle入门一
绘制一个时钟(python-turtle入门一
163 0
|
Python
Python turtle可以用的颜色
Python turtle可以用的颜色
227 0
|
Python
Python经典编程习题100例:第64例:利用ellipse 和 rectangle 画图
Python经典编程习题100例:第64例:利用ellipse 和 rectangle 画图
86 0
用turtle库绘制图形(fractalcurves)
用turtle库绘制图形(fractalcurves)
121 0
用turtle库绘制图形(fractalcurves)
用turtle库绘制图形(bytedesign)
用turtle库绘制图形(bytedesign)
203 0
用turtle库绘制图形(bytedesign)
|
前端开发 图形学 Python
10分钟轻松学会 Python turtle 绘图(上)
10分钟轻松学会 Python turtle 绘图
275 0