# 实验1，2

from turtle import*
from random import random, randint
def moveto(x,y):
penup()
goto(x,y)
pendown()

setup(800,600)
speed(100)

for i in range(9):

rgb=tuple(random() for i in range(3))
color(rgb)
begin_fill()
end_fill()
hideturtle()
done()

# 实验3

from turtle import*

def square(size=50,rgb='pink'):

pencolor(rgb)
for i in range(4):
fd(size)
lt(90)
def main():
setup(800,600)
speed(10)
n=10
for i in range(n):
square(80,'orange')
lt(360/n)
hideturtle()

done()
if __name__=='__main__':
main()

# 实验4

from turtle import*

setup(800,600)
pencolor('pink')
speed(0)

n=10
for i in range(n):
for j in range(2):
circle(80,90)
lt(90)
right(360/n)
hideturtle()
done()

# 实验5

from turtle import*

setup(800,600)
bgcolor('black')
pencolor('white')
speed(0)

angle=0
size=2

n=10
for i in range(n):
for j in range(4):
fd(size)
angle+=72
seth(angle)
size+=5

hideturtle()
done()

# 实验6

from turtle import*
from random import random,randint

setup(800,600)
speed(0)

def rect(wide,high,rgb):
fillcolor(rgb)
begin_fill()
penup()
for i in range(2):
fd(wide)
left(90)
fd(high)
left(90)
fd(wide)
pendown()
end_fill()

for i in range(20):
rgb=tuple(random() for i in range(3))
rect(20,40,rgb)

hideturtle()
done()

posted @ 2022-06-13 22:03  Embeddd  阅读(4)  评论(0编辑  收藏  举报