实验八

from turtle import *

def square(size=50, rgb='pink'):
    '''绘制正方形
    参数size指定边长
    参数rgb指定画笔颜色
    如果没有给参数,采用默认值
    '''
    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()

rom turtle import *

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

n = 10
for i in range(n):
    # 绘制一片花瓣
    for j in range(2):
        speed(0)
        circle(80, 90)
        left(90)

    right(360/n)

hideturtle()
done()

from turtle import *

setup(800, 600)
bgcolor('black')
pencolor('red')
speed(0)
angle = 0
size = 2

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

hideturtle()
done()

def main():
    pass

if __name__ == '__main__':
    main()
from turtle import*
from random import random
setup(800,600)
goto((800-10*20)/2-400,0)
def r(w,h,n):
    speed(0)
    c = tuple( random() for i in range(3) )
    color(c)
    begin_fill()
    for i in range(1,5):
        if i%2!=0:
            fd(w)
        else:
            fd(h)
        left(90)
    end_fill()
    hideturtle()
w=10;h=20;n=20
for i in range(1,n+1):
    r(w,h,n)
    goto((800-10*20)/2-400+w*i,0)
done()

 

posted @ 2022-06-09 17:04  沉迷学习ing  阅读(6)  评论(2编辑  收藏  举报