【Python】第6次练习:叠加等边三角形、正n边形、五角星的绘制
1、叠加等边三角形的绘制
import turtle
turtle.setup(1300,800,0,0)
pythonsize=1
turtle.pensize(pythonsize)
turtle.pencolor("black")
turtle.seth(60)
turtle.fd(100)
turtle.seth(-60)
turtle.fd(100)
turtle.seth(180)
turtle.fd(50)
turtle.seth(120)
turtle.fd(50)
turtle.seth(0)
turtle.fd(50)
turtle.seth(-120)
turtle.fd(50)
turtle.seth(180)
turtle.fd(50)
2、绘制正n边形
import time
import turtle
turtle.setup(800,600,0,0)
pythonsize=1
turtle.pensize(pythonsize)
turtle.pencolor("black")
turtle.fillcolor("red")
turtle.begin_fill()
count = 1
n=eval(input())
while count <= n:
turtle.forward(100)
turtle.right(360/n)
time.sleep(0.5)
count += 1
turtle.end_fill()
3、五角星绘制
import turtle
turtle.setup(1300,800,0,0)
pythonsize=1
turtle.pensize(pythonsize)
turtle.pencolor("black")
turtle.fillcolor("red")
turtle.begin_fill()
count = 1
while count <= 5:
turtle.forward(100)
turtle.right(144)
count += 1
turtle.end_fill()