实验八
作者:互联网
实验三
1 from turtle import * 2 3 def square(size=50, rgb='orange'): 9 pencolor(rgb) 10 for i in range(4): 11 fd(size) 12 left(90) 13 14 15 def main(): 16 setup(800, 600) 17 speed(0) 18 19 n = 10 20 for i in range(n): 21 square(80) 22 left(360/n) 23 24 hideturtle() 25 done() 26 27 28 if __name__ == '__main__': 29 main()
实验四
1 from turtle import * 2 3 setup(800, 600) 4 pencolor('pink') 5 speed(0) 6 7 n = 10 8 for i in range(n): 9 # 绘制一片花瓣 10 for j in range(2): 11 circle(80, 90) 12 left(90) 13 14 right(360/n) 15 16 hideturtle() 17 done()
实验五
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 = 8 12 for i in range(n): 13 for j in range(5): 14 fd(size) 15 angle += 72 16 seth(angle) 17 size += 5 18 19 hideturtle() 20 done()
实验六
from turtle import *
from random import random
setup(800, 600)
speed(0)
n=100
for i in range(10):
rgb = tuple( random() for i in range(3) )
color(rgb)
begin_fill()
lt(90)
fd(20)
lt(90)
fd(n)
lt(90)
fd(40)
lt(90)
fd(n)
lt(90)
fd(20)
rt(90)
n-=10
end_fill()
n=100
for i in range(10):
rgb = tuple( random() for i in range(3) )
color(rgb)
begin_fill()
rt(90)
fd(20)
lt(90)
fd(n)
lt(90)
fd(40)
lt(90)
fd(n)
lt(90)
fd(20)
lt(90)
n-=10
end_fill()
hideturtle()
done()
实验总结:
画图的时候程序不够简洁。但是以我的笨头脑只能暂时想出这种方式
标签:10,20,实验,range,lt,fd,90 来源: https://www.cnblogs.com/gengyang035/p/16359201.html