+ 1

i have tried developing a bmi calculator but it always shows error

code is like name1 = "aklesh" weight_kg = 70 length_m = 1.8 def bmi_calculator(name1, weight_kg, length_m): bmi=weight_kg/length_m**2 print("bmi:") print(bmi_calculator) if bmi<25: return name1 + "you are overweight" else: return name1 + 'you are not overweight' if bmi == 25: return name+"you are good" result= bmi_calculator(name1, weight_kg, length_m) print(result) please help!

28th Aug 2018, 12:43 PM
Aklesh Dahal
Aklesh Dahal - avatar
1 ответ
+ 7
I think you just had the greater than symbol the wrong way round. I tried this in Pydroid and it worked as expected: name1 = "aklesh" weight_kg = 70 length_m = 1.8 def bmi_calculator(name1, weight_kg, length_m): bmi=weight_kg/length_m**2 print("bmi:") print(bmi) if bmi > 25: return name1 + "you are overweight" elif bmi == 25: return name+"you are good" else: return name1 + 'you are not overweight' result= bmi_calculator(name1, weight_kg, length_m) print(result)
28th Aug 2018, 6:35 PM
Rob Bailiff
Rob Bailiff - avatar