Open roberthsu2003 opened 1 month ago
try:
name=str(input("請輸入姓名"))
height=float(input('請輸入身高'))
weight=float(input('請輸入體重'))
bmi=weight/(((height*0.01))**2)
if bmi<18.5:
grade="體重過輕"
elif bmi<24:
grade="正常範圍"
elif bmi<27:
grade="過重"
elif bmi<30:
grade="輕度肥胖"
elif bmi<35:
grade="中度肥胖"
elif bmi>=35:
grade="重度肥胖"
print(f"{name}的bmi為{bmi},為{grade}")
except ValueError:
print("格式錯誤")
else:
print("應用程式結束")
name=input('請輸入姓名:')
try:
h=float(input('請輸入身高(cm):'))
w=float(input('請輸入體重(kg):'))
except Exception:
print('格式錯誤')
bmi=round(w/(h*0.01)**2,ndigits=2)
print(f'{name}您好:\n您的BMI值是:{bmi}')
if bmi<18.5:
print('體重:過輕')
elif bmi<24:
print('體重:正常')
elif bmi<27:
print('體重:過重')
elif bmi<30:
print('體重:輕度肥胖')
elif bmi<35:
print('體重:中度肥胖')
else:
print('體重:重度肥胖')
name=input('請輸入姓名:')
try:
height=float(input('請輸入身高(cm):'))
weight=float(input('請輸入體重(kg):'))
except ValueError:
print('格式錯誤')
else:
BMI=round(weight/((height*0.01)**2),ndigits=2)
print(f'{name}您好')
print(f'您的BMI值是:{BMI}')
if BMI>=35:
grade='重度肥胖'
elif BMI>=30:
grade='中度肥胖'
elif BMI>=27:
grade='輕度肥胖'
elif BMI>=24:
grade='過重'
elif BMI>=18:
grade='正常'
else:
grade='過輕'
print(f'體重:{grade}')
name = input("請輸入姓名: ")
try:
height = float(input("請輸入身高(cm): "))
if (height <= 0):
raise ValueError
except ValueError:
print("身高輸入錯誤")
else:
try:
weight = float(input("請輸體重(kg): "))
if (weight <=0):
raise ValueError
except ValueError:
print("體重輸入錯誤")
else:
BMI = weight / (height * 0.01) ** 2
if (BMI < 18.5):
weight_result = "體重過輕"
elif (BMI < 24):
weight_result = "正常範圍"
elif (BMI < 27):
weight_result = "過重"
elif (BMI < 30):
weight_result = "輕度肥胖"
elif (BMI < 35):
weight_result = "中度肥胖"
else:
weight_result = "重度肥胖"
print(f"{name}您好")
print(f"BMI值是: {round(BMI, ndigits= 2)}")
print(f"體重: {weight_result}")
print("程式結束")
name=str(input('請輸入姓名:'))
try:
h=float(input('請輸入身高cm:'))
if h<=0:
raise Exception
w=float(input('請輸入體重kg:'))
if w<=0:
raise Exception
except Exception:
print('格式錯誤')
else:
BMI=round(w/((h*0.01)**2),ndigits=2)
print(f'{name}你好:')
print(f'你的BMI值為:{BMI}')
if BMI<18.5:
print('體重:過輕')
elif BMI<24:
print('體重:正常')
elif BMI<27:
print('體重:過重')
elif BMI<30:
print('體重:輕度肥胖')
elif BMI<35:
print('體重:中度肥胖')
else:
print('體重:重度肥胖')
print('應用程式結束')
name = input("請輸入姓名:")
try:
height = float(input("請輸入身高(cm):"))
weight = float(input("請輸入體重(kg):"))
if not (height > 0 and weight > 0):
raise Exception("身高或體重不可為零或負數")
except ValueError:
print("格式輸入錯誤")
except Exception:
print("範圍輸入錯誤")
else:
BMI = round(weight/((height*0.01)**2), ndigits = 2)
if BMI < 18.5:
grade = "過輕"
elif BMI < 24:
grade = "正常"
elif BMI < 27:
grade = "過重"
elif BMI < 30:
grade = "輕度肥胖"
elif BMI < 35:
grade = "中度肥胖"
else:
grade = "重度肥胖"
print(f"{name}您好:")
print(f"BMI值是:{BMI}")
print(f"體重:{grade}")
print("應用程式結束")
name = input("請輸入姓名:") try: height = float(input("請輸入身高(cm):"))
if (height <= 0):
raise ValueError
except ValueError: print("身高輸入錯誤!") else: try: weight = float(input("請輸入體重(kg)")) if (weight <= 0): raise ValueError except ValueError: print("體重輸入錯誤!") else: m = float(height / 100) BMI = round(weight / m**2,ndigits=2)
if BMI < 18.5:
print("您的體重過輕!")
elif 18.5 <= BMI < 24:
print("您的體重適中!")
elif 24 <= BMI < 27:
print("您的體重過重!")
elif 27 <= BMI < 30:
print("您的體重為輕度肥胖!")
elif 30 <= BMI < 35:
print("您的體重為中度肥胖!")
else:
print("您的體重為重度肥胖!")
print(f"{name}的BMI為{BMI}") print("應用程式結束!")
try:
name=str(input("請輸入姓名"))
cm=int(input("請輸入身高(cm)"))
kg=int(input("請輸入體重(kg)"))
if (cm<=0 or kg<=0):
raise Exception
except ValueError:
print("格式輸入錯誤")
except Exception:
print("身高或體重輸入錯誤")
else:
m=float(cm/100)
BMI=float(round(kg/m**2,2))
if BMI<18.5:
kg_check="過輕"
elif BMI<24:
kg_check="適中"
elif BMI<27:
kg_check="過重"
elif BMI<30:
kg_check="輕度肥胖"
elif BMI<35:
kg_check="中度肥胖"
else:
kg_check="過度肥胖"
print(f"{name}您好:")
print(f"BMI值是:{BMI}")
print(f"體重:{kg_check}")
name = str(input('請輸入姓名:'))
try:
height = int(input('請輸入身高(cm):'))
weight = int(input('請輸入體重(kg):'))
except ValueError:
print("格式錯誤")
else:
BMI = round(weight / ((0.01 * height) ** 2), ndigits=1)
if BMI >=35:
result = '重度肥胖'
elif BMI >=30:
result = '中度肥胖'
elif BMI >= 27:
result = '輕度肥胖'
elif BMI >=24:
result = '過重'
elif BMI >=18.5:
result = '正常'
else:
result = '過輕'
print(name+'您好:')
print(f'您的BMI值是:{BMI}')
print(f'您的體重{result}')
name = input("請輸入姓名:")
try:
height_cm = float(input("請輸入身高(cm):"))
weight = float(input("請輸入體重(kg):"))
except ValueError:
print("格式錯誤")
height_m = height_cm / 100
bmi = round(weight / height_m ** 2, ndigits=2)
if bmi < 18.5:
grade = "過輕"
elif bmi < 24:
grade = "正常"
elif bmi < 27:
grade = "過重"
elif bmi < 30:
grade = "輕度肥胖"
elif bmi < 35:
grade = "中度肥胖"
else:
grade = "重度肥胖"
print(f"{name}您好:")
print(f"您的BMI值是:{bmi}")
print(f"體重:{grade}")
N = str(input("請輸入姓名:"))
try:
H = float(input("請輸入身高(cm):"))
W = float(input("請輸入體重(kg):"))
except ValueError:
print("格式錯誤")
except Exception:
print("不知名的錯誤")
else:
BMI = round(W / (H/100)**2, ndigits=2)
print(f"{N}您好: 您的BMI值是:{BMI}")
if BMI < 18.5:
BMI_scope = "體重過輕"
elif BMI >= 18.5 and BMI < 24:
BMI_scope = "正常範圍"
elif BMI >= 24 and BMI < 27:
BMI_scope = "過重"
elif BMI >= 27 and BMI < 30:
BMI_scope = "輕度肥胖"
elif BMI >= 30 and BMI < 35:
BMI_scope = "中度肥胖"
else:
BMI >= 35
BMI_scope = "重度肥胖"
print(f"體重:{BMI_scope}")
print("應用程式結束")
try:
name=str(input("請輸入姓名"))
cm=int(input("請輸入身高(cm)"))
kg=int(input("請輸入體重(kg)"))
if (cm<=0 or kg<=0):
raise Exception
except ValueError:
print("格式輸入錯誤")
except Exception:
print("身高或體重輸入錯誤")
else:
m=float(cm/100)
BMI=float(round(kg/m**2,2))
if BMI<18.5:
kg_check="過輕"
elif BMI<24:
kg_check="適中"
elif BMI<27:
kg_check="過重"
elif BMI<30:
kg_check="輕度肥胖"
elif BMI<35:
kg_check="中度肥胖"
else:
kg_check="過度肥胖"
print(f"{name}您好:")
print(f"BMI值是:{BMI}")
print(f"體重:{kg_check}")
a=input('NAME:')
try:
h=float(input('身高(cm):'))/100
w=float(input('體重(kg):'))
except ValueError:
print('數值格式錯誤')
b=round(w/(h**2),2)
if b>=35:
G="重度肥胖。"
elif b>=30:
G="中度肥胖。"
elif b>=27:
G="輕度肥胖。"
elif b>=24:
G="過重。"
elif b>=18.5:
G="正常。"
else:
G="過輕。"
print(f"{a}您好,您的BMI値為{b},體重屬於{G}")
try:
name=input("請輸入姓名:")
cm=float(input("請輸入身高(cm):"))
kg=float(input("請輸入體重(kg):"))
except ValueError:
print('格式錯誤')
BMI=round(kg/(cm/100)**2,2)
if BMI>=35:
grade="重度肥胖"
elif BMI >=30:
grade="中度肥胖"
elif BMI >=27:
grade="輕度肥胖"
elif BMI >=24:
grade="過重"
elif BMI >=18.5:
grade="正常範圍"
else:
grade="體重過輕"
print(f"{name}您好,您的BMI值為:{BMI},體重屬於:{grade}")
name = input("請輸入姓名:")
try:
kg = float(input("請輸入體重(kg):"))
cm = float(input("請輸入身高(cm):"))
if (cm<=0 or kg<=0):
raise Exception
except Exception:
print("格式錯誤")
else:
m = float(cm / 100)
bmi = kg/ m**2
if 24 > bmi >= 18.5:
x = "正常"
elif bmi < 18.5 :
x = "過輕"
elif 27 > bmi >= 24:
x = "過重"
elif 30 > bmi >= 27:
x = "輕度肥胖"
elif 35 > bmi >= 30:
x = "中度肥胖"
elif bmi >= 35:
x = "重度肥胖"
print(f'{name}您好:')
print(f'您的BMI值是:{bmi}')
print(f'體重:{x}')
name=input('請輸入姓名:')
try:
height=float(input('請輸入身高(cm):'))
weight=float(input('請輸入體重(kg):'))
except ValueError:
print("格式錯誤")
else:
BMI=round(weight/((height*0.01)**2),ndigits=2)
print(f'{name}您好')
print(f'您的BMI值:{BMI}')
if BMI>=35:
grade='重度肥胖'
elif BMI>=30:
grade='中度肥胖'
elif BMI>=27:
grade='輕度肥胖'
elif BMI>=24:
grade='過重'
elif BMI>=18:
grade='正常'
else:
grade='過輕'
print(f'體重:{grade}')
name =(input("name:"))
kg = float(input("weight:"))
m = float(input("height:"))
bmi = kg/ m**2
print(f'hello:{name}')
print(f'your BMI is:{bmi}')
if ((bmi >= 18.5) | (bmi <= 24)):
print( "normal")
else :
if bmi < 18: print( "too thin")
elif bmi>=24: print( "too heavy")
elif bmi>=27: print( "simple fat")
elif bmi>=30: print( "normal fat")
elif bmi>=35: print( "hardly fat")
name = input("請輸入姓名:")
try:
height = float(input("請輸入身高(cm):"))
if (height <= 0):
raise ValueError
except ValueError:
print("身高輸入錯誤!")
else:
try:
weight = float(input("請輸入體重(kg)"))
if (weight <= 0):
raise ValueError
except ValueError:
print("體重輸入錯誤!")
else:
m = float(height / 100)
BMI = round(weight / m**2,ndigits=2)
if BMI < 18.5:
print("您的體重過輕!")
elif 18.5 <= BMI < 24:
print("您的體重適中!")
elif 24 <= BMI < 27:
print("您的體重過重!")
elif 27 <= BMI < 30:
print("您的體重為輕度肥胖!")
elif 30 <= BMI < 35:
print("您的體重為中度肥胖!")
else:
print("您的體重為重度肥胖!")
print(f"{name}的BMI為{BMI}")
print("應用程式結束!")
import math
try:
name=str(input('請輸入姓名'))
high=float(input('請輸入身高(cm)'))
highb=high/100
weight=float(input('請輸入體重(kg)'))
except ValueError:
print("格式錯誤")
else:
BMI=round(weight/(highb**(2)),ndigits=2)
print(f'{name}你好:')
print(f'您的BMI值是:{BMI}')
if BMI<18.5:
print('體重為過輕')
elif BMI<24:
print('體重為正常')
elif BMI<27:
print('體重為過重')
elif BMI<30:
print('體重為輕度肥胖')
elif BMI<35:
print('體重為中度肥胖')
else:
print('體重為重度肥胖')
#計算BMI,判斷體重正常與否
try:
name = input("請輸入姓名:")
height = float(input("請輸入身高(cm):"))
weight = float(input("請輸入體重(kg):"))
BMI = round(weight/(height/100)**2,ndigits=2)
if BMI<18.5:
result="過輕"
elif BMI<24:
result="正常"
elif BMI<27:
result="過重"
elif BMI<30:
result="輕度肥胖"
elif BMI<35:
result="中度肥胖"
else:
result="重度肥胖"
print(f'{name}您好:')
print(f'您的BMI值是:{BMI}')
print(f'體重:{result}')
except ValueError:
print('格式錯誤')
int main(void){ char name[20]; float height; float weight;
printf("請輸入姓名:");
scanf("%s",name);
printf("請輸入身高(cm):");
scanf("%f",&height);
printf("請輸入體重(kg):");
scanf("%f",&weight);
double BMI = weight /(height/100)/(height/100);
printf("%s您好:\n");
printf("您的BMI值為:%.2lf \n",BMI);
if (BMI < 18.5){
printf("體重:過輕\n");}
else if (BMI <24){
printf("體重:正常\n");}
else if(BMI <27){
printf("體重:過重\n");}
else if(BMI <30){
printf("體重:輕度肥胖\n");}
else if(BMI <35){
printf("體重:中度肥胖\n");}
else{
printf("體重:重度肥胖\n");}
return 0;
}
name=input('請輸入姓名:')
try:
height=float(input('請輸入身高(cm):'))
weight=float(input('請輸入體重(kg):'))
except ValueError:
print('格式錯誤')
else:
BMI=round(weight/((height*0.01)**2),ndigits=2)
print(f'{name}您好')
print(f'您的BMI值是:{BMI}')
if BMI>=35:
grade='重度肥胖'
elif BMI>=30:
grade='中度肥胖'
elif BMI>=27:
grade='輕度肥胖'
elif BMI>=24:
grade='過重'
elif BMI>=18:
grade='正常'
else:
grade='過輕'
print(f'體重:{grade}')
輸入:
輸出:
xxx您好: BMI值是:23.45 體重:正常