python海龟图

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,100 ):
    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 )

你可能感兴趣的:(Python基础)