class BMI:
def __init__(self,xingming,nianling,tizhong,shengao):
self.xingming = xingming
self.nianling = nianling
self.tizhong = tizhong
self.shengao = shengao
self.bmi = tizhong/(shengao*shengao)
t = self.bmi
if t < 18.5:
n = "偏瘦"
elif t >= 18.5 and t < 24:
n = "正常"
elif t >= 24 and t < 30:
n = "偏胖"
self.jiankang = n
def the_BMI(self):
print("{n}".format(n=self.xingming),"的BMI是:{n}".format(n=self.bmi),"他/她的健康状况是:{n}".format(n=self.jiankang))
def the_age(self):
print("{n}".format(n=self.xingming),"的年龄是:{n}".format(n=self.nianling))
def the_weighht(self):
print("{n}".format(n=self.xingming),"的体重是:{n}".format(n=self.tizhong))
def the_high(self):
print("{n}".format(n=self.xingming),"的身高是:{n}".format(n=self.shengao))
```import tkinter
import tkinter.messagebox as mb
import tkinter as tk
import tkinter.simpledialog as dl
import random
def msgbox():
tkinter.messagebox.showinfo(title="xuehao",message=xuehao.get())
root = tkinter.Tk()
l=tkinter.Label(root,text="This is lable")
l.pack()
mb.showinfo("bmi指数计算器","欢迎来到bmi指数计算器")
number=random.randrange(1,100)
input_number3=dl.askfloat("身高","输入您的身高")
input_number4=dl.askfloat("bmi指数","输入您期望的bmi指数")
weight1=input_number3*input_number3*input_number4
output_dialogl="您期望的体重为: "+str(weight1)
mb.showinfo("期望体重",output_dialogl)
button = tkinter.Button(root,text='点击弹出',command=msgbox)
button.place(x=20, y=20, height=30,width=80)
xuehao = tkinter.StringVar(root)
entryXuehao = tkinter.Entry(root, width=150, textvariable=xuehao)
entryXuehao.place(x=100, y=5, width=150, height=20)
#w=label = tkinter.Label(text="输入姓名,年龄,,体重,身高",)
#w.pack()
root.mainloop()
12.10学习记录
最新推荐文章于 2024-01-18 15:41:48 发布