Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.4 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
6a15cadf5f240d05a264955b Challenge 317: BMI Calculator 29 challenge-317

--description--

Given a weight in pounds and a height in inches, return the BMI (Body Mass Index) rounded to one decimal place.

To get BMI: divide the weight by the height squared, then multiply the result by 703.

--hints--

calculate_bmi(180, 70) should return 25.8.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(calculate_bmi(180, 70), 25.8)`)
}})

calculate_bmi(140, 64) should return 24.0.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(calculate_bmi(140, 64), 24.0)`)
}})

calculate_bmi(160, 76) should return 19.5.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(calculate_bmi(160, 76), 19.5)`)
}})

calculate_bmi(200, 60) should return 39.1.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(calculate_bmi(200, 60), 39.1)`)
}})

calculate_bmi(150, 68) should return 22.8.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(calculate_bmi(150, 68), 22.8)`)
}})

--seed--

--seed-contents--

def calculate_bmi(weight, height):

    return weight

--solutions--

def calculate_bmi(weight, height):
    return round((weight / (height * height)) * 703, 1)