实验六
实验任务三、
from turtle import* def square(size=50, rgb = 'green'): pencolor(rgb) for i in range(4): fd(size) left(90) def main(): setup(800, 600) speed(0) for i in range(10): square(80) left(36) hideturtle() done() if __name__ == '__main__': main()
实验任务四、
from turtle import * setup(800, 600) pencolor('green') for i in range(10): for i in range(2): circle(80, 90) left(90) right(36) hideturtle() done()
实验任务五、
from turtle import * speed(0) setup(800, 600) bgcolor('black') pencolor('green') angle = 0 size = 2 for i in range(10): for j in range(5): fd(size) angle += 72 seth(angle) size += 5 hideturtle() done()
实验任务六、
from turtle import * import random speed(0) setup(800, 600) penup() goto(-100,0) pendown() n=-100 speed(10) for i in range(20): rgb = tuple(random.random() for i in range(3)) begin_fill() fd(10) left(90) fd(20) left(90) fd(10) left(90) fd(20) left(90) color(rgb) end_fill() goto(n+10,0) n+=10 hideturtle() done()