其他分享
首页 > 其他分享> > 实验8

实验8

作者:互联网

# 用矩形绘制花瓣
from turtle import *
def square(size=50,rgb='pink'):
    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,'orange')
        left(360/n)

    hideturtle()
    done()

from turtle import *
setup(800,600)
pencolor('pink')

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

    right(360/n)

hideturtle()
done()

# 绘制螺旋状正方形、五边形
from turtle import *
help(circle)
setup(800,600)
bgcolor('black')
pencolor('white')
speed(0)

angle = 0
size = 2

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

hideturtle()
done()

from turtle import *
from random import random

def rect(width, high):
    for i in range(2):
        fd(width)
        right(90)
        fd(high)
        right(90)


setup(800, 600)
speed(0)
penup()
goto(-80,0)
pendown()
right(180)

for i in range(20):
    rgb = tuple(random() for i in range(3))
    color(rgb)
    begin_fill()
    rect(8, 16)
    end_fill()
    penup()
    goto(-80+8*i+8, 0)
    pendown()

hideturtle()
done()

 

标签:turtle,600,range,实验,90,import,size
来源: https://www.cnblogs.com/1awake8/p/16372522.html