Open roberthsu2003 opened 2 months ago
age = 17
#單一程式區塊
if age >= 18:
print("可以考駕照")
print("有投票權")
print("應用程式結束")
height = float(input("請輸入身高(cm): "))
weight = float(input("請輸入體重(kg): "))
BMI = weight / (height / 100) ** 2
print(f"你的身高是 {height}cm, 體重是 {weight}kg, BMI是 {round(BMI, 5)}")
name = input("請輸入您的姓名")
height = float(input("請輸入您的身高(cm)"))
weight=float(input("請輸入您的體重(kg)"))
BMI = float(weight/(height/100)**2)
print(f"您的姓名是:{name}")
print(f"您的BMI值是:{round(BMI,ndigits=2)}")
name = input("請輸入您的姓名:")
cm = float(input("請輸入您的身高(cm):"))
weight = float(input("請輸入您的體重(kg):"))
bmi = float(round((weight / ( cm / 100 ) ** 2),ndigits=2))
if 18.25 <= bmi <= 24:
bmitype = "正常範圍"
else:
bmitype = "異常範圍"
print(f"個人資訊 - 姓名: {name}, 身高: {cm} cm, 體重: {weight}, BMI: {bmi}")
print(f"BMI計算結果:{bmitype}")
p= (input("請輸入您的大名(繁體中文)"))
weight = float(input ("請輸入您的體重(公斤):"))
height = float(input ("請輸入您的身高(公尺):"))
bmi=weight/(height**2)
print(p,"的BMI是",bmi, )
Python code:
# BMI 計算, refer to https://toolboxtw.com/zh-TW/calculator/bmi
# BMI = weight(kg) / height(m)^2
print("BMI 計算,請輸入")
# Input name
name = input("姓名: ")
# Input height
height = float(input("身高(公分): "))
# Input weight
weight = float(input("體重(公斤): "))
# Output user information
bmi = weight / (height / 100)**2
# Get the result
if bmi < 18.5:
result = "過輕"
elif bmi >= 18.5 and bmi < 24:
result = "正常"
elif bmi >= 24 and bmi < 27:
result = "過重"
else:
result = "肥胖"
# Output BMI and result
print(f"\n{name} - 身高: {height}cm,體重: {weight}Kg, BMI: {round(bmi, 2)}({result})")
Result:
N=input("請輸入您的姓名")
H=float(input("請輸入您的身高(請輸入cm單位)"))
W=float(input("請輸入您的體重(請輸入kg單位)"))
BMI=(round((W/(H/100)**2),ndigits=2))
if 18<=BMI<=24:
bmi="健康"
else:
bmi="不健康"
print(f"姓名:{N},身高{H},體重{W}BMI{BMI}")
print(f"BMI數值{bmi}")
nane = ( input ( " 請輸入您的姓名:" ) )
height = float ( input ( " 請輸入身高(cm) : " ) )
weight = float ( input ( " 請輸入體重(kg) : " ) )
BMI = weight / ( height / 100 ) ** 2
print (f" 您的姓名是:{nane}" )
print (f" 你的身高是{height}cm\n 體重是{weight}kg\n BMI是 {round(BMI, 5)} \n" )
name = input("請輸入您的姓名")
height = float(input("請輸入您的身高(cm)"))
weight=float(input("請輸入您的體重(kg)"))
BMI = float(weight/(height/100)**2)
print("您的姓名是:",name)
print(f"(您的身高(cm):)",{height})
print(f"(您的體重(kg):)",{weight})
print(f"您的BMI值是:{round(BMI,ndigits=2)}")
name = input("請輸入您的姓名")
height = float(input('請輸入您的身高(cm)'))
weight = float(input('請輸入您的體重(kg)'))
BMI = weight / (height/100)** 2
print(f"您的姓名為:{name}")
print(f"您的BMI值為:{ round( BMI , ndigits = 1 )}")
name = input("您的姓名")
height = float(input("請輸入您的身高"))
weight = float(input("請輸入您的體重"))
bmi = float(round((weight/(height/100)**2),ndigits=2))
a , b , c , d , e = 18.5 , 24 , 27 , 30 , 35
if bmi < a:
result = "體重過輕"
elif a <= bmi < b:
result = "正常"
elif b < bmi <= c:
result = "過重"
elif c < bmi <= d:
result = "輕度肥胖"
elif d < bmi <= e:
result = "中度肥胖"
else:
result = "重度肥胖"
print(f"姓名:{name} 體重:{weight} 身高:{height}")
print(f"BMI值:{bmi} 體態:{result}")
BMI計算
name = input("請輸入您的姓名")
height = float(input("請輸入您的身高(cm)"))
weight = float(input("請輸入您的體重(kg)"))
BMI = float(weight/(height/100)**2)
print(f"您的姓名是:{name}")
print(f"您的BMI值是:{round(BMI,ndigits=1)}")
name= input("請輸入您的姓名") height = float(input("請輸入您的身高(cm)")) 體重 = float(input("請輸入您的體重(kg)"))
BMI = 浮點數(體重/(身高/100)**2)
print(f"您的姓名是:{name}") print(f"您的BMI值為:{round(BMI,ndigits=1)}")``
name = input("請輸入您的姓名")
height = float(input("請輸入您的身高(cm)"))
weight = float(input("請輸入您的體重(kg)"))
BMI = round(weight / (height/100) **2, ndigits=2)
print(f"您的姓名是:{name}, 身高(cm):{height}, 體重(kg):{weight}")
print(f"您的BMI值是:{BMI}")
name=input("請輸入您的姓名:")
height=float(input("請輸入您的身高(cm)"))
weight=float(input("請輸入您的體重(kg)"))
BMI=float(weight/(height/100)**2)
print(f"您的姓名是:{name}")#計算BMI值
print(f"您的BMI值是:{round(BMI,ndigits=2)}")
name = input("請輸入你的名字:")
height = float(input("請輸入你的身高(cm):"))
weight = float(input("請輸入你的體重:"))
bmi = float(round(weight / ((height/100)**2),ndigits=2))
if 18.5 <= bmi <= 24 :
BMI ="正常範圍"
else:
BMI ="異常範圍"
print(f"你的名字:{name},BMI:{bmi}")
print(f"BMI值結果:{BMI}")
x=input('Name:')
h=float(input('height:'))
w=float(input('weight:'))
bmi=w/(h/100)**2
print(f'Your name is:{x}\nYour BMI is:{bmi}')
> >練習計算BMI值
Python code:
# BMI 計算, refer to [https://toolboxtw.com/zh-TW/calculator/bmi)]
# BMI = weight(kg) / height(m)^2
print("BMI 計算,請輸入")
# Input name
name = input("姓名: ")
# Input height
height = float(input("身高(公分): "))
# Input weight
weight = float(input("體重(公斤): "))
# Output user information
bmi = weight / (height / 100)**2
# Get the result
if bmi < 18.5:
result = "過輕"
elif bmi >= 18.5 and bmi < 24:
result = "正常"
elif bmi >= 24 and bmi < 27:
result = "過重"
else:
result = "肥胖"
# Output BMI and result
print(f"\n{name} - 身高: {height}cm,體重: {weight}Kg, BMI: {round(bmi, 2)}({result})")
name = input("請輸入您的名字:")
cm = float(input("請輸入您的身高(cm):"))
kg = float(input("請輸入您的體重(kg):"))
bmi = kg / (cm/100) ** 2
print(f"您的名字是:{name}")
print(f"您的BMI值是:{round(bmi,ndigits = 2)}")
name = input("請輸入您的姓名")
height = float(input("請輸入您的身高(cm)"))
weight=float(input("請輸入您的體重(kg)"))
BMI = float(weight/(height/100)**2)
print(f"您的姓名是:{name}")
print(f"您的BMI值是:{round(BMI,ndigits=2)}")
輸入:
輸出: