Part I
Part I
Stage Development I:
Defining the function and hypotenuse argument representing the lengths of the other two
legs of a right triangle. Started out by importing the math module to access the sqrt function for
import math
hypotenuse using the Pythagorean theorem, which states that the square of the hypotenuse is
equal to the sum of the squares of the other two legs. We assign the calculated value to a variable
hyp.
# Test call
print(hypotenuse(3, 4))
Output: 5.0
A, b = 3, 4
Explanation:
Calculates the hypotenuse of a right triangle using the Pythagorean theorem. Args: a (float):
Length of the first leg. b (float): Length of the second leg. Returns: float: Length of the
hypotenuse. """
Explanation:
Then I used the pythagorean theorem to implement the function in Python code.
I added given records for other random inputs to get new outputs.
This program can be run multiple times to get the hypotenuse for any function.
PART II
For the portfolio, I chose to create a function that calculates the Body Mass Index (BMI) and
provides a health classification based on the calculated value. BMI is a widely used metric to
assess health risks related to weight and height. This would be a good portfolio showing for a
This function is practical and demonstrates computational skills, conditional logic, and user-
Function Requirements
1. Accept two inputs: `weight` (in kilograms) and `height` (in meters).
\[ \text{BMI} = \frac{\text{weight}}{\text{height}^2}
\]
# Test call
Output:
None
# Test call
22.857142857142858
category = "Underweight"
category = "Overweight"
else:
category = "Obesity"
Output:
Refine the function to format the BMI to 2 decimal places and improve readability.
Args:
Returns:
category = "Underweight"
category = "Overweight"
else:
category = "Obesity"
# Test call
Output:
Final Testing
# Test 1: Underweight
(16.33, 'Underweight')
# Test 2: Overweight
Output:
(26.12, 'Overweight')
# Test 3: Obesity
Output:
(32.65, 'Obesity')
Final Code
Args:
Returns:
category = "Underweight"
category = "Overweight"
else:
category = "Obesity"
Final Outputs
show off for a health company, my function allows for the primary calculation of BMI to weight