1.画一个颜色渐变的circle
import turtle
t = turtle.Pen()
t.pensize(3)
for x in range(360):
t.pencolor(1, 0, x * 1.0 / 360.0)
t.forward(1)
t.left(1)
画一个可爱的小house
import turtle import math t = turtle.Pen() t.pensize(3) # the main part of the building t.forward(200) t.right(90) t.forward(200) t.right(90) t.forward(200) t.right(90) t.forward(200) # the sloped roof t.left(90) t.forward(50) t.right(135) t.forward(150 * math.sqrt(2)) t.right(90) t.forward(150 * math.sqrt(2)) t.right(135) t.forward(180) # go to the window t.penup() t.right(90) t.forward(30) t.pendown() # draw the window t.right(90) t.forward(60) t.left(90) t.forward(60) t.left(90) t.forward(60) t.left(90) t.forward(60)
3.画一个螺旋迷宫
import turtle
t = turtle.Pen()
t.pensize(3)
for x in range(1,31):
t.right(90)
t.forward(x * 5)
总结:
turtle就是画画神器哦



