簡體   English   中英

BMI 和 Karvonen 計算器 python

[英]BMI and Karvonen Calculator python

https://softchalkcloud.com/lesson/serve/njUvRZqCb1mDIH/html

這是我正在做的項目,離完成還差得很遠。 我不斷得到這個 output 進行重量轉換計算,lbs 到 kg function weight_in_kg at 0x000002028E06BAC0 我不知道為什么

def weight_in_kg(lbs):
    wieght_in_kg = lbs * 0.45359237
    return weight_in_kg

def height_meters(inches):
    height_meters = inches / 39.3700787
    return height_meters

def height_square_meters(meters):
    height_sqaure_meters = meters ** 2
    return height_square_meters

def get_weight(prompt):
    weight_in_pounds = input(prompt)
    while not weight_in_pounds.isdigit():
        print('Please enter an integer ')
        weight_in_pounds = input('Try and enter your weight in pounds again')
    weight_in_pounds = int(weight_in_pounds)
    return weight_in_pounds

def get_height(prompt):
    height_inches = input(prompt)
    while not height_inches.isdigit():
        print('Please enter and integer ')
        height_inches = input('Try and enter your height in inches again')
    height_inches = int(height_inches)
    return height_inches


patient_weight_pounds = get_weight('Enter your weight in pounds ')
patient_weight_kg = weight_in_kg(patient_weight_pounds)

print(patient_weight_kg)

test = weight_in_kg(100)
print(test)

當你修改你的weight_in_kg function時,你會收到正確的output。我認為你的問題是你返回了function的memory地址,而不是結果。

def weight_in_kg(lbs):
    weight_in_kgs = lbs * 0.45359237
    return weight_in_kgs

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM