elif
This commit is contained in:
parent
307c51539c
commit
c0244b5822
3 changed files with 35 additions and 6 deletions
|
|
@ -1,4 +1,3 @@
|
|||
# test_arithmetic.py
|
||||
def calculate_bmi(weight, height):
|
||||
bmi = weight / (height ** 2)
|
||||
|
||||
|
|
|
|||
20
test/ruby/25.out
Normal file
20
test/ruby/25.out
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
def calculate_bmi(weight, height)
|
||||
bmi = weight / height ** 2
|
||||
if bmi < 18.5
|
||||
category = "Underweight"
|
||||
else
|
||||
if bmi < 25
|
||||
category = "Normal"
|
||||
else
|
||||
if bmi < 30
|
||||
category = "Overweight"
|
||||
else
|
||||
category = "Obese"
|
||||
end
|
||||
end
|
||||
end
|
||||
return "BMI: #{bmi}, Category: #{category}"
|
||||
end
|
||||
print(calculate_bmi(70, 1.75), "\n")
|
||||
print(calculate_bmi(90, 1.80), "\n")
|
||||
print(calculate_bmi(50, 1.65), "\n")
|
||||
Loading…
Add table
Add a link
Reference in a new issue