实验8

 from turtle import *

 def square(size=50, rgb='orange'):
      pencolor(rgb)
     for i in range(4):
         fd(size)
         left(90)
 
 
 def main():
     setup(800, 600)
     speed(0)
 
     n = 10
     for i in range(n):
         square(80)
         left(360/n)
 
     hideturtle()
     done()
 
 
 if __name__ == '__main__':
     main()

 

 

 

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)
        left(90)

    right(360/n)

hideturtle()
done()

 

 

 

from turtle import *

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

angle = 0
size = 2

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

hideturtle()
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()  

 

posted @ 2022-06-09 19:14  青桔水溶C  Views(5)  Comments(2Edit  收藏  举报