1、五角星
import turtle as t
a = eval(input("请输入旋转度数:"))
def linearmove():
for i in range(5):
t.forward(300)
t.right(144)
t.left(a)
t.color('red', 'red')
t.begin_fill()
linearmove()
t.end_fill()
t.done
2、叠加等边三角形
import turtle as t
t.setup(600, 600, None,None)
t.pu()
t.fd(-120)
t.pensize(5)
t.width(5)
t.pencolor("darkgreen")
t.pd()
t.fd(250)
t.seth(120)
t.pencolor("black")
t.fd(250)
t.seth(-120)
t.pencolor("blue")
t.fd(250)
t.pencolor("purple")
t.fd(250)
t.seth(0)
t.pencolor("green")
t.fd(250)
t.pencolor("gold")
t.fd(250)
t.seth(120)
t.pencolor("yellow")
t.fd(250)
t.seth(-120)
t.pencolor("grey")
t.fd(250)
t.seth(120)
t.pencolor("pink")
t.fd(250)
3、爱心
from turtle import *
def curvemove():
for i in range(200):
right(1)
forward(1)
color('red','pink')
begin_fill()
left(140)
forward(111.65)
curvemove()
left(120)
curvemove()
forward(111.65)
end_fill()
done()
4、螺旋线
import turtle as t
a = input("请输入旋转度数:")
y = eval(a)
def draw_spin():
colores = ['red', 'purple', 'blue', 'green', 'yellow', 'orange']
t.bgcolor('black')
for x in range(200):
t.pencolor(colores[x % 6])
t.width(x / 100 + 1)
t.forward(x)
t.left(y)
draw_spin()
5、身体质量指数
#计算BMI
weight = float(input("请输入体重(kg):"))
height = float(input("请输入身高(m):"))
bmi = weight/(height*height)
print("您的BMI指数为:{:.2f}".format(bmi))