实验8
作者:互联网
task3
1 from turtle import* 2 3 def square(size=50,rgb='orange'): 4 pencolor(rgb) 5 for i in range(4): 6 fd(size) 7 left(90) 8 9 def main(): 10 setup(800,600) 11 speed(0) 12 13 n=10 14 for i in range(n): 15 square(80) 16 left(360/n) 17 18 hideturtle() 19 done() 20 21 if __name__=='__main__': 22 main()
task4
1 from turtle import* 2 3 setup(800,600) 4 pencolor('pink') 5 6 n=10 7 for i in range(n): 8 for j in range(2): 9 circle(80,90) 10 left(90) 11 12 right(360/n) 13 hideturtle() 14 done()
task5
1 from turtle import* 2 3 setup(800,600) 4 bgcolor('black') 5 pencolor('white') 6 speed(0) 7 8 angle=0 9 size=2 10 11 n=10 12 for i in range(n): 13 for j in range(4): 14 fd(size) 15 angle+=72 16 seth(angle) 17 size+=5 18 19 hideturtle() 20 done()
task6
1 from turtle import* 2 from random import random 3 4 def moveto(x,y): 5 penup() 6 goto(x,y) 7 pendown() 8 9 def rect(width,length,color): 10 begin_fill() 11 fillcolor(color) 12 for x in range(1,5): 13 if x%2==1: 14 n=length 15 else: 16 n=width 17 forward(n) 18 right(90) 19 end_fill() 20 21 22 setup(800,600) 23 speed(0) 24 25 for j in range(20): 26 moveto(-20*10+20*j,0) 27 rgb=tuple(random() for i in range(3)) 28 rect(70,20,rgb) 29 30 31 hideturtle() 32 done()
标签:turtle,10,20,range,实验,import,size 来源: https://www.cnblogs.com/dyh222/p/16358775.html