roberthsu2003 / __2024_05_05_sunday__

AI 人工智慧開發入門_python
29 stars 2 forks source link

練習:計算BMI值 #10

Open roberthsu2003 opened 2 months ago

roberthsu2003 commented 2 months ago

輸入:

輸出:

截圖 2024-05-12 下午4 46 26
roberthsu2003 commented 2 months ago
age = 17

#單一程式區塊
if age >= 18:
    print("可以考駕照")
    print("有投票權")

print("應用程式結束")
截圖 2024-05-12 下午4 51 23
eddie3256 commented 2 months ago
height = float(input("請輸入身高(cm): "))
weight = float(input("請輸入體重(kg): "))

BMI = weight / (height / 100) ** 2

print(f"你的身高是 {height}cm, 體重是 {weight}kg, BMI是 {round(BMI, 5)}")

image

Austin20051226 commented 2 months ago

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=2)}")

螢幕擷取畫面 2024-05-12 170023

OrbAkatsuki commented 2 months ago

計算BMI值

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}")

image

gosh5566 commented 2 months ago
p= (input("請輸入您的大名(繁體中文)"))
weight = float(input ("請輸入您的體重(公斤):"))
height = float(input ("請輸入您的身高(公尺):")) 

bmi=weight/(height**2)

print(p,"的BMI是",bmi, )

image

jonathan-sean commented 2 months ago

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: image

Remainder1996 commented 2 months ago
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}")

未命名

Rola0605 commented 2 months ago

練習計算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" )

2024512練習正確版

sanchangj commented 2 months ago
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)}")

image

calvinliao223 commented 2 months ago

程式碼如下

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 )}")

image

wjoker444116 commented 2 months ago

( if、elif、else )練習

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}")

image

GraceWCH commented 2 months ago

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)}")

截圖 2024-05-13 下午10 29 23

aaaasssddfghjkl commented 2 months ago

name= input("請輸入您的姓名") height = float(input("請輸入您的身高(cm)")) 體重 = float(input("請輸入您的體重(kg)"))

BMI = 浮點數(體重/(身高/100)**2)

print(f"您的姓名是:{name}") print(f"您的BMI值為:{round(BMI,ndigits=1)}")``

charlywang11 commented 2 months ago

計算BMI值


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}")

練習_計算BMI值

mimionana commented 2 months ago

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)}")
螢幕擷取畫面 2024-05-15 204757
shadow40744398 commented 2 months ago
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}")

註解 2024-05-16 024833

whosKrista commented 2 months ago
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}')

螢幕擷取畫面 2024-05-18 212230

Chenhochia commented 2 months ago

> >練習計算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})")
截圖 2024-05-19 上午9 33 33
bess122428 commented 2 months ago

以下是我的程式碼

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)}")

bmi

EdwardHsu0212 commented 2 months ago

計算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=2)}")
截圖 2024-05-30 下午4 32 12