turtle图形绘制

利用turtle库绘制一个正方形螺旋线,。

import turtle

turtle.speed("fastest")
turtle.pensize(2)
for x in range (100):
    turtle.forward(2*x)
    turtle.left(90)

turtle图形绘制_第1张图片

 

 

绘制斜螺旋线

import turtle

turtle.speed("fastest")
turtle.pensize(2)
for x in range (100):
    turtle.forward(2*x)
    turtle.left(91)

turtle图形绘制_第2张图片

绘制彩色斜螺旋线

import turtle

turtle.pensize(2)
turtle.speed("fastest")
colors=["red","yellow",'purple','blue']
for x in range (100):
    turtle.pencolor(colors[x%4])
    turtle.forward(2*x)
    turtle.left(91)

turtle图形绘制_第3张图片
彩色蟒蛇绘制

 

#e2.1DrawPython.py
import turtle
turtle.setup(650,350,200,200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.penside(25)
turtle.pencolor("purple")
turtle.seth(-40)
for i in range(4):
    turtle.circle(40,80)
    turtle.circle(-40,80)
turtle.circle(40,80/2)
turtle.fd(40)
turtle.circle(16,180)
turtle.fd(40*2/3)

turtle图形绘制_第4张图片

 

 

 

你可能感兴趣的:(Python,python,机器学习)