以下所有代码只需在记事本保存,后缀名改为py(前提是必须要有python环境),然后保存双击运行就可以看到运行效果。菜鸡一个(大佬勿喷!)
1、画画
import turtle
turtle .speed("fastest")
turtle.pensize(1)
for y in range(200):
turtle.forward(3 * y)
turtle.left(20)
turtle.right(175)
2、画螺旋
import turtle as t
t.color("green")
for i in range(270):
t.fd(i)
t.left(70)
t.done()
3、金字塔
import turtle
import time
turtle.speed("fastest")
turtle.pensize(2)
for x in range(100):
turtle.forward(2 * x)
turtle.left(90)
time.sleep(3)
4、太阳
from turtle import*
color('red','yellow')
begin_fill
while True:
forward(200)
left(170)
if abs(pos())<1:
break
end_fill()
done()