2017-02-28 39 views
-2
def male_resting_metabolic_rate(weight,height,age): 

    '''Takes in the weight, height, and age of a male individual 
    and returns the resting metabolic rate 

Example answers: 
    male_resting_metabolic_rate(80,180,48) = 1751''' 

    male_resting_metabolic_rate = int((88.4+13.4*weight)+(4.8*height)-(5.68* age)) 

if __name__ == "__main__": 
print("This program will calculate the resting metabolic rate of an individual") 

    #Gather the inputs for the functions 

weight = input("What is your weight in kilograms?") 
height = input("What is your height in centimeters?") 
age = int(input("What is your age?" + "(between 1-110):")) 

print("Your resting metabolic rate is",male_resting_metabolic_rate(input,input,input)) 

なぜ10行目と24行目にエラーがありますか?答えがかなり明白であれば、私は謝罪します。TypeError:*: 'float'および 'builtin_function_or_method'のサポートされていないオペランドタイプ

+2

'入力、入力、input'を:代わりに、あなたは上で定義された変数の3倍' input'方法!!また、2つの変数の整数への変換がありません。 –

+0

ここにはいくつかの問題があります。最初は 'input'が文字列を返すので、乗算する前にウェイトを数値に変換する必要があります。 'male_resting_metabolic_rate(入力、入力、入力))'は意味がありません、あなたは何をしようとしていましたか? – roganjosh

+0

@ Jean-FrançoisFabreどのように変数を整数に変換するのですか?再び私はこれが本当に基本的なように感じることを謝罪します! –

答えて

-1

少なくとも2つの間違いが見つかった:pythonで "return"を指定して値を返す必要があります。また、あなたはこれを試して名前ない「入力」

によってパラメータを渡すために必要な:

def male_resting_metabolic_rate(weight,height,age): 

    '''Takes in the weight, height, and age of a male individual 
    and returns the resting metabolic rate 

    Example answers: 
    male_resting_metabolic_rate(80,180,48) = 1751''' 

    return int((88.4+13.4*weight)+(4.8*height)-(5.68* age)) 

if __name__ == "__main__": 
    print("This program will calculate the resting metabolic rate of an individual") 

    #Gather the inputs for the functions 

    weight = float(input("What is your weight in kilograms?")) 
    height = float(input("What is your height in centimeters?")) 
    age = int(input("What is your age?" + "(between 1-110):")) 

    print("Your resting metabolic rate is",male_resting_metabolic_rate(weight, height, age)) 
+0

私はこれのための解決策を完成させました。質問にすべての混乱した書式の回答を投稿しないでください。エディタで修正する必要があります。 – roganjosh

+0

@roganjosh私はそれをお詫びします - 私は同じ返信でコードとコメントの書式を設定する方法を知らなかった。私は問題を考え出した、ありがとう! –

+0

@J。コメントの書式設定にバッククウックを使用します。コードブロックの場合は、コピー/ペーストして全体を強調表示し、 'ctrl' +' k'を使用します。しかし、この回答にはフォーマットの改善が必要です。ひどくフォーマットされた質問と回答の理由はありません。 – roganjosh

関連する問題