Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

error in blood_pressure and LDL undefined def function_name(arg1, arg2, etc.) # this line is the signature # commands go here # more commands # result

error in blood_pressure and LDL

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedundefined

def function_name(arg1, arg2, etc.) # this line is the signature # commands go here # more commands # result = ... return result # this line returns the result of your computations The following are the functions you must implement: blood pressure(systolic, diastolic) Description: Blood pressure is measured using two numbers. The first number, called systolic blood pressure, measures the pressure in your blood vessels when your heart beats. The second number, called diastolic blood pressure, measures the pressure in your blood vessels when your heart rests between beats. The American Heart Association categorizes the blood pressure according to the following chart (verbatim copy from the official site): Blood Pressure Category Normal Elevated Hypertension Stage 1 Hypertension Stage 2 Hypertensive Crisis Systolic less than 120 120 - 129 130 - 139 140 or higher higher than 180 AND AND OR OR AND/OR Diastolic less than 80 less than 80 80 - 89 90 or higher higher than 120 Assume that normal corresponds to risk level 1.0, elevated corresponds to risk level 1.1, and so forth (the max is hypertensive crisis which corresponds to risk level 1.4). In case a measurement can be classified in more than one categories, we assign it to the one with the highest risk. Calculate this risk level as well as the mean arterial pressure, defined as: systolic + 2 diastolic meanpressure = 3 Parameters: systolic (int) is the systolic blood pressure, diastolic (int) is the diastolic blood pressure Return value: The function returns the product of risk level times the mean arterial pressure as a float rounded to 2 decimals (hint: there is a Python built-in function for rounding) Examples: blood pressure(106,75) blood pressure(148, 90) 85.33 142.13 standard_BMI(weight, height, ISU) Description: The body mass index BMI is defined as the body mass divided by the square of the body height, and is universally expressed in units of kg/m2, resulting from mass in kilograms and height in meters. This function calculates the BMI value given three parameters. Parameters: weight (int) is the body mass of the person, height (float) is the height of the person, and ISU (boolean) is a flag to indicate whether the weight and height are given in the International System of Units or not. If ISU is True then weight is in kilos and height is in meters, otherwise weight is in ounces and height is in inches. If you need to convert the parameters use the following simplified formulas: 1 kilo = 35 ounces, 1 inch = 0.025 meters Return value: The calculated value of BMI as a float expressed in kg/m2 rounded to 2 decimals Examples: standard_BMI(75, 1.76, True) standard_BMI(3500, 79, False) 24.21 25.64 - BMI_chart(weight, height, age, gender) Description: The BMI is a convenient rule thumb used to broadly categorize a person as underweight, normal weight, overweight, or obese based on some charts. The following is the chart for adults (greater or equal to 18 years): BMI below 18.5 from 18.5 (included) to 25 (included) from 25 (excluded) to 30 (included) higher than 30 category underweight normal weight overweight obese And the following is the chart for male children: BMI below 14 from 14 (included) to 19 (included) from 19 (excluded) to 22 (included) higher than 22 category underweight normal weight overweight obese In case of female children the above chart values are increased by 1 BMI unit, i.e. 14 becomes 15, 19 becomes 20, and 22 becomes 23. In case of female children the above chart values are increased by 1 BMI unit, i.e. 14 becomes 15, 19 becomes 20, and 22 becomes 23. Please keep in mind that this function does not calculate the body mass index itself but is calling the standard_BMI function you have implemented before. Parameters: weight (int) in kilograms, height (float) in meters, age (int) is age in whole years, gender (string) is either 'male' or 'female' Return value: It returns a string containing one of the four possible values: 'underweight', 'normal', 'overweight', 'obese'. Make sure you have no typos otherwise the tester will fail. Examples: BMI_chart(75, 1.76, 43, 'female') BMI_chart(100, 1.87, 20, 'male') 'normal' 'overweight' 4 HCT(red_cells, total_cells, age, gender) Description: The hematocrit (HCT) is a blood test that measures the volume percentage (vol%) of the red cells in blood. For adults, it is normally 40.7% to 50.3% for men and 36.1% to 44.3% for women. For children (below 18 years), the normal range is 36% to 40% regardless of gender. All values are inclusive. Parameters: red_cells (int) is the number of red cells in the blood, total_cells (int) is the total number of cells in the blood, age (int) is age in whole years, gender (string) is either 'male' or 'female'. Return value: The function returns True if the HCT is normal and False otherwise. It also returns False if the total number of cells is less than 1 million because the result in that case is inconclusive. Examples: HCT(206567899, 454677789, 18, 'male') HCT(194005321,594677789, 67, 'female') True False LDL(total, HDL, trig, age, gender) Description: Higher levels of LDL (low-density lipoprotein) increase the risk of cardiovascular disease. LDL is calculated with the Friedewald equation: LDL = totalcholesterol HDL cholesterol k. triglycerides where k is usually 0.2. If triglycerides concentration is not between 11.3 and 43.5 (values inclusive), the result is inaccurate and therefore we discard the last term i.e. k=0). However, if both total cholesterol and triglycerides levels are elevated (i.e. greater than 250 and 43.5 respectively) then we use a modified version of the Friedewald equation where k has an initial value of 0.19 and is reduced by 0.01 for each whole 10 units of increase of total above 250, e.g. if total is 251-259 then k is 0.19, if total is 260-269 then k is 0.18, and so forth. Note: Hard coding is not allowed, your code must work with any value of total Parameters: total (int) is the total cholesterol, HDL (int) is the "good" cholesterol, trig (float) is the number of triglycerides, age (int) is age in whole years, gender (string) is either 'male' or 'female' Return value: The function returns an integer value between 0 and 5 that indicates the level of risk (5 is the highest) based on the following rules: Adults: if LDL is less than 120 then risk is 0. Otherwise, the level of risk starts at 1, maxes out at 5, and is increased by 1 for each whole 20 units of LDL, i.e. from 120 (inclusive) to 140 (exclusive) risk is 1, from 140 (inclusive) to 160 (exclusive) risk is 2, and so forth. Children (less than 18 years): if LDL is less than 100 then risk is 0. Otherwise, the level of risk starts at 1, maxes out at 5, and is increased by 1 for each whole 15 units of LDL. Adults: if HDL is less than 40 for men or less than 50 for women, the level of risk that is calculated based on LDL is increased by 1. To the contrary, if HDL is more than 70 regardless of gender, the level of risk that is calculated based on LDL is reduced by 1. Examples: LDL(257, 50, 44.1, 67, 'female') LDL(174, 62, 34.8, 23, 'male') 4 0 def blood pressure (systolic, diastolic): risklevel = 1.0 if systolic =120 and diastolic = 130 and diastolic =140 or diastolic >=90: risklevel =1.3 if (systolic >=180 or diastolic >=120): risklevel =1.4 meanpressure = (systolic + (2*diastolic))/3 return round(risklevel * meanpressure, 2) 3 def LDL (total, HDL,trig, age, gender): k=0 if trig >= 11.3 and trig 250 and trig > 43.5: k = 0.20 - 0.01 * ((total - 250)/10) LDL = total HDL k * trig risk = 5 if age >= 18: if LDL =120 and LDL =140 and LDL =160 and LDL =180 and LDL = 100 and LDL = 115 and LDL = 130 and LDL = 145 and LDL 70: risk = risk 1 return risk == - ======== FAIL: test_blood_pressure_8 (__main__.AllTests) Traceback (most recent call last): File "testerP2.py", line 123, in test_blood_pressure_8 def test_blood_pressure_8 (self):self.assertEqual(blood pressure(133, 89), 124.4) AssertionError: 103.67 != 124.4 FAIL: test_blood_pressure_12 (_main_ ..AllTests) Traceback (most recent call last): File "testerP2.py", line 127, in test_blood_pressure_12 def test_blood_pressure_12 (self):self.assertEqual(blood_pressure (172, 120), 178.53) AssertionError: 192.27 != 178.53 ========== FAIL: test_LDL_8 (__main__.AllTests) Traceback (most recent call last): File "testerp2.py", line 191, in test_LDL_8 def test_LDL_8 (self):self.assertEqual(LDL (173, 51, 43.5, 8, 'female'), 1) AssertionError: 2 != 1 FAIL: test_LDL_11 (__main_ .AllTests) Traceback (most recent call last): File "testerP2.py", line 194, in test_LDL_11 def test_LDL_11 (self):self.assertEqual(LDL (251, 83, 43.6, 17, 'male'), 4) AssertionError: 3 != 4 FAIL: test_LDL_12 (_main_ AllTests) Traceback (most recent call last): File "testerp2.py", line 195, in test_LDL_12 def test_LDL_12_(self):self.assertEqual(LDL (299, 79, 43.6, 5, 'male'), 5) AssertionError: 4 != 5 FAIL: test_LDL_17 (_main AllTests) Traceback (most recent call last): File "testerP2.py", line 200, in test_LDL_17 def test_LDL_17 (self):self.assertEqual(LDL (289, 41, 71.9, 78, 'female'), 5) AssertionError: 6 != 5 FAIL: test_LDL_18 (_main__.AllTests) Traceback (most recent call last): File "testerP2.py", line 201, in test_LDL_18 def test_LDL_18 (self):self.assertEqual(LDL (188, 71, 43.6, 58, 'female'), 0) AssertionError: -1 != 0 Ran 80 tests in 0.014s FAILED (failures=9) 71/80 Required test cases passed (worth 1 each) Score based on test cases: 71.00/80 (71.00*1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago