❶ python計算BMI值
廢話不多說,改進版繼續上程序哈:
def bmi():
name=input('Name:')
height=input('Height(m):')
weight=input('Weight(kg):')
BIM=float(float(weight)/(float(height)**2))
print('您的BIM指數為:',BIM)
if BIM <18.5:
print('你太輕了!')
elif BIM<=25:
print('標准體重哦哦!')
elif BIM<=32:
print('您有點微胖哦哦!')
else:
print('您太胖了,該減肥了')
bmi()
for i in range(10):
choose =input('您是否願意繼續計算BMI(y/n):')
if choose=='y':
bmi()
else:
break
❷ python語言計算BMI值,感謝求解!
sg=input('你的身高多少(米):')
tz=input('你的體重多少(公斤):')
BMI=round(float(tz)/float(sg)**2,1)
ifBMI<18.5:
print('BMI={0},{1}'.format(BMI,'偏瘦'))
elif18.5<=BMI<24.9:
print('BMI={0},{1}'.format(BMI,'標准'))
elif25.0<=BMI<29.9:
print('BMI={0},{1}'.format(BMI,'超重'))
elif25<=BMI:
print('BMI={0},{1}'.format(BMI,'肥胖'))
這是委託我讀五年級的兒子寫的。^_^
❸ 怎麼用python算bmi 簡單編程 在線等
weight=int(raw_input("請輸入體重(千克):"))
height=int(raw_input("請輸入身高(米):"))
BMI=weight/(height*height)
print "BMI=",BMI
if BMI<19:
print「輕體重"
elif BMI>=19 and BMI<25:
print"健康身體"
elif BMI>=25 and BMI<28:
print"超重「
else:
print"肥胖」
raw_input("press any key to quit.")
❹ python bmi公式怎麼用
weight=int(raw_input("請輸入體重(千克):"))
height=int(raw_input("請輸入身高(米):"))
BMI=weight/(height*height)
print "BMI=",BMI
if BMI<19:
print「輕體重"
elif BMI>=19 and BMI<25:
print"健康身體"
elif BMI>=25 and BMI<28:
print"超重「
else:
print"肥胖」
raw_input("press any key to quit.")
❺ 用Python小張的年齡是26 體重是72.5千克,身高是1.82m則輸出26,72.5,1.82
這是Python語言中字典的應用,先創建一個字典,將小張的年齡,體重,身高以鍵值對的方式寫入字典,再列印key值就得到相應的數據了!
❻ python的單位轉換問題
round()函數用錯了啊,你應該寫成:
lb = round(fx*2.205, 2)
這樣。
round(x[, n])
Return the floating point value x rounded to n digits after the decimal point. If n is omitted, it defaults to zero. Delegates to x.__round__(n).
For the built-in types supporting round(), values are rounded to the closest multiple of 10 to the power minus n; if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). The return value is an integer if called with one argument, otherwise of the same type as x.
❼ 求助:用Python實現國際單位換算
知道進制就可以換算啦,每一個換算用一種方法實現。如:
def kg2g(kg):
return 1000 * kg
def g2kg(g):
return g / 1000
❽ python重量計算編程
x1=50
y1 = x1 + 0.5*10
y2 = y1 * 0.165
❾ Python讓用戶輸入自己的體重,以克為單位轉化為千克,但是現在我不知道怎麼讓用戶輸入的代碼
defconvert_kg(g):
returnstr(g/1000.0)+'kg'
print(convert_kg(int(input('請輸入體重(克):'))))
python3版本。python2的話中文要用unicode。想學好python可以關注我的課程,謝謝