Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified code/__pycache__/bmiCalculator.cpython-310.pyc
Binary file not shown.
Binary file modified code/__pycache__/test_bmiCalculator.cpython-310-pytest-6.2.5.pyc
Binary file not shown.
18 changes: 14 additions & 4 deletions code/bmiCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -83,7 +92,8 @@ def inputHeight():



if __name__ == "__main__":
if __name__ == "__main__":

print("BMI Calculator for Adults (20+ Years Old)")

weight = inputWeight()
Expand Down
16 changes: 8 additions & 8 deletions code/test_bmiCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)))



Expand Down