import turtle
height = float(turtle.textinput(‘身高’, ‘请输入你的身高(米)’))
weight = float(turtle.textinput(‘体重’, ‘请输入你的体重(千克)’))
BMI = weight / height**2
BMI = round(BMI, 1)
text = ‘’
color = ‘’
if BMI < 18.5:
color = ‘blue’
text = ‘偏瘦’
elif 18.5 <= BMI < 24:
color = ‘green’
text = ‘正常’
elif 24 <= BMI < 28:
color = ‘yellow’
text = ‘超重’
elif BMI >= 28:
color = ‘red’
text = ‘肥胖’
turtle.fillcolor(color)
turtle.begin_fill()
turtle.forward(weight)
turtle.left(90)
turtle.forward(height100)
turtle.left(90)
turtle.forward(weight)
turtle.left(90)
turtle.forward(height100)
turtle.end_fill()
turtle.penup()
turtle.goto(0, -50)
turtle.pendown()
文字信息:‘BMI指数:’+ BMI数值 + text
info = ‘BMI指数:’ + str(BMI) + ’ ’ + text
turtle.write(info, align=‘center’, font=(‘simhei’, 20))
turtle.hideturtle()
turtle.done()
😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😂😂😃😄😄👿😉😉😊😊😊😊😊😊😓😒😍😌😌😌😍😒😓😔😔😖😔😒😏😌☺☺😌😏😒😒😒👿😄😂😂☺😌😌😒😓😓😄😃😌😜😞😞😒😄😍😜😝😞😒😄😍😜😝😒😄😃😚😜😝😒😒😌😚😝😏😃😌😚😜😏😄😃😚😜😏😏😍😚😜😏😏