diff --git a/code/__pycache__/bmiCalculator.cpython-310.pyc b/code/__pycache__/bmiCalculator.cpython-310.pyc index 4ae34c4..8a058a0 100644 Binary files a/code/__pycache__/bmiCalculator.cpython-310.pyc and b/code/__pycache__/bmiCalculator.cpython-310.pyc differ diff --git a/code/__pycache__/test_bmiCalculator.cpython-310-pytest-6.2.5.pyc b/code/__pycache__/test_bmiCalculator.cpython-310-pytest-6.2.5.pyc index 3e5860a..6992533 100644 Binary files a/code/__pycache__/test_bmiCalculator.cpython-310-pytest-6.2.5.pyc and b/code/__pycache__/test_bmiCalculator.cpython-310-pytest-6.2.5.pyc differ diff --git a/code/bmiCalculator.py b/code/bmiCalculator.py index 0d87f75..306711e 100644 --- a/code/bmiCalculator.py +++ b/code/bmiCalculator.py @@ -25,8 +25,11 @@ def height(inH): # Calculate bmi -def bmi(w, h): - bmiVal = weight(w) / height(h) +def bmi_val(w, h): + return (weight(w) / height(h)) + +def bmiCategory(bmiVal): + category = "" #if (bmiVal < 18.5): @@ -39,8 +42,14 @@ def bmi(w, h): else: category = "Obese" - return bmiVal, category + return category + + +def bmi(w, h): + bmiVal = bmi_val(w, h) + category = bmiCategory(bmiVal) + return bmiVal, category # Get weight @@ -83,7 +92,8 @@ def inputHeight(): -if __name__ == "__main__": +if __name__ == "__main__": + print("BMI Calculator for Adults (20+ Years Old)") weight = inputWeight() diff --git a/code/test_bmiCalculator.py b/code/test_bmiCalculator.py index 8ec0776..0ad0655 100644 --- a/code/test_bmiCalculator.py +++ b/code/test_bmiCalculator.py @@ -6,7 +6,7 @@ """ import unittest import numpy as np -from bmiCalculator import weight, height, bmi, bmiCategory +from bmiCalculator import weight, height, bmi_val, bmiCategory # Average male height: 5'9" = 69" @@ -40,26 +40,26 @@ def test_height(self): - def test_bmi(self): + def test_bmi_val(self): # ~ Underweight Boundary Test # Test at weight = 122.1, height = 69" - self.assertEqual(bmi(122.1, 69), np.divide(np.multiply(122.1, 0.45), np.power(np.multiply(69, 0.025), 2))) + self.assertEqual(bmi_val(122.1, 69), np.divide(np.multiply(122.1, 0.45), np.power(np.multiply(69, 0.025), 2))) # ~ Healthy Weight Boundary Test # Test at weight = 122.4, height = 69" - self.assertEqual(bmi(122.4, 69), np.divide(np.multiply(122.4, 0.45), np.power(np.multiply(69, 0.025), 2))) + self.assertEqual(bmi_val(122.4, 69), np.divide(np.multiply(122.4, 0.45), np.power(np.multiply(69, 0.025), 2))) # Test at weight = 164.6, height = 69" - self.assertEqual(bmi(164.6, 69), np.divide(np.multiply(164.6, 0.45), np.power(np.multiply(69, 0.025), 2))) + self.assertEqual(bmi_val(164.6, 69), np.divide(np.multiply(164.6, 0.45), np.power(np.multiply(69, 0.025), 2))) # ~ Overweight Boundary Test # Test at weight = 164.7, height = 69" - self.assertEqual(bmi(164.7, 69), np.divide(np.multiply(164.7, 0.45), np.power(np.multiply(69, 0.025), 2))) + self.assertEqual(bmi_val(164.7, 69), np.divide(np.multiply(164.7, 0.45), np.power(np.multiply(69, 0.025), 2))) # Test at weight = 197.7, height = 69" - self.assertEqual(bmi(197.7, 69), np.divide(np.multiply(197.7, 0.45), np.power(np.multiply(69, 0.025), 2))) + self.assertEqual(bmi_val(197.7, 69), np.divide(np.multiply(197.7, 0.45), np.power(np.multiply(69, 0.025), 2))) # ~ Obese Boundary Test # Test at weight = 197.8, height = 69" - self.assertEqual(bmi(197.8, 69), np.divide(np.multiply(197.8, 0.45), np.power(np.multiply(69, 0.025), 2))) + self.assertEqual(bmi_val(197.8, 69), np.divide(np.multiply(197.8, 0.45), np.power(np.multiply(69, 0.025), 2)))