Question

For this task, you will be writing a Python script that will determine a person’s blood...

For this task, you will be writing a Python script that will determine a person’s blood pressure category. The program should prompt the user for the systolic and diastolic blood pressure readings. Based on the readings and using the table below, the program will determine and output the category.

Category Systolic Diastolic
Hypotension 50-89 35-59
Normal 90-119 60-79
Pre-hypertension 120-139 80-89
Mild Hypertension 140-159 90-99
Moderate Hypertension 160-179 100-109
Severe Hypertension 180-209 110-119
Very Severe Hypertension 210-239 120-135
  
Other Requirements for the Program:
 Your program should first check for invalid readings and should output a message for invalid readings. Systolic or Diastolic readings that fall below or above the readings in the table are invalid. 

If a person’s readings put them in two different categories, the higher category should be selected. For example, someone with a blood pressure reading of 118/85 would be categorized as normal for the systolic reading and pre-hypertension for the diastolic reading. The program should output pre-hypertension. However, if a person has one reading that is normal and one reading in Hypotension (Low), they should be categorized as Hypotension which means low blood pressure.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Refer to the screenshots for better understanding of code and indentation

Code -

# function to find systolic category and level, return list of [level, category]
def systolic_category(reading):
   reading = int(reading) #converting reading to integer
  
   if reading >= 50 and reading <= 89:
       return [1, "Hypotension"]
   elif reading <= 119:
       return [2,"Normal"]
   elif reading <= 139:
       return [3, "Pre-hypertension"]
   elif reading <= 159:
       return [4, "Mild Hypertension"]
   elif reading <= 179:
       return [5, "Moderate Hypertension"]
   elif reading <= 209:
       return [6, "Severe Hypertension"]
   elif reading <= 239:
       return [7, "Very Severe Hypertension"]
  
  
# function to find diastolic category and level, return list of [level, category]  
def diastoloc_category(reading):
   reading = int(reading) #converting reading to integer
  
   if reading >= 35 and reading <= 59:
       return [1, "Hypotension"]
   elif reading <= 79:
       return [2, "Normal"]
   elif reading <= 89:
       return [3, "Pre-hypertension"]
   elif reading <= 99:
       return [4, "Mild Hypertension"]
   elif reading <= 109:
       return [5, "Moderate Hypertension"]
   elif reading <= 119:
       return [6, "Severe Hypertension"]
   elif reading <= 135:
       return [7, "Very Severe Hypertension"]
      
      

def main():
  
   # taking input, removing leading and trailing spaces and converting to integer
   systo = input("Enter Systolic reading: ").strip()
   systo = int(systo)
   diasto = input("Enter Diastolic reading: ").strip()
   diasto = int(diasto)
  
   # checkinh if readings are out of range and output invalid readings if invalid
   if systo < 50 or systo > 239:
       print("Invalid Systolic readings")
   elif diasto > 135 or diasto < 35:
       print("Invalid Diastolic readings")
   else: #if reading are valid
      
       systo_cat = systolic_category(systo) # getting systolic reading category and level
       diasto_cat = diastoloc_category(diasto) # getting diastolic reading category and level
      
       if systo_cat[0] == 2 and diasto_cat[0] == 1: # checking if one reading is normal and other is Hypotension
           print(diasto_cat[1])
       elif systo_cat[0] == 1 and diasto_cat[0] == 2: # checking if one reading is normal and other is Hypotension
           print(systo_cat[1])
       else: # printing higher category of the two
           if systo_cat[0] >= diasto_cat[0]:
               print(systo_cat[1])
           elif diasto_cat[0] > systo_cat[0]:
               print(diasto_cat[1])

  
main()

Screenshots

Code

Output

Add a comment
Know the answer?
Add Answer to:
For this task, you will be writing a Python script that will determine a person’s blood...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a MATLAB program that will determine the condition of a nuclear reactor. The user will...

    Write a MATLAB program that will determine the condition of a nuclear reactor. The user will input the temperature and pressure values read from gages. The program will determine the state of the nuclear reactor and then output using fprintf the following statement: The Nuclear Reactor is categorized as: followed by the correct Category.   Other Requirements for the Program: If the readings put the condition in two different categories, the higher category should be selected. For example, a reactor with...

  • Vital Signs: Blood Pressure a. What is blood pressure? What is the purpose of assessing blood...

    Vital Signs: Blood Pressure a. What is blood pressure? What is the purpose of assessing blood pressure? b. What is the standard unit for measuring blood pressure? What is the difference between systolic blood pressure and diastolic blood pressure? c. Various factors can affect blood pressure. Some of these are listed below. Discuss the differences with each of these factors. i) age example: BP is lower in children than in adults. ii) gender iii) race iv) diurnal rhythm v) weight...

  • Blood pressure is a measure of the blood force against the walls of the arteries. Blood...

    Blood pressure is a measure of the blood force against the walls of the arteries. Blood pressure that is consistently more than 140/90 mm Hg is considered high, but for people with diabetes, 130/80 mm Hg is considered high. Normal blood pressure is below 120/80 mm Hg. The larger value represents the pressure when the heart contracts and pushes blood out (systolic), and the smaller value is the lowest pressure when the heart relaxes between beats (diastolic). Consider a population...

  • Blood pressure is a measure of the blood force against the walls of the arteries. Blood...

    Blood pressure is a measure of the blood force against the walls of the arteries. Blood pressure that is consistently more than 140/90 mm Hg is considered high, but for people with diabetes, 130/80 mm Hg is considered high. Normal blood pressure is below 120/80 mm Hg. The larger value represents the pressure when the heart contracts and pushes blood out (systolic), and the smaller value is the lowest pressure when the heart relaxes between beats (diastolic). Consider a population...

  • Blood pressure is a measure of the blood force against the walls of the arteries. Blood...

    Blood pressure is a measure of the blood force against the walls of the arteries. Blood pressure that is consistently more than 140/90 mm Hg is considered high, but for people with diabetes, 130/80 mm Hg is considered high. Normal blood pressure is below 120/80 mm Hg. The larger value represents the pressure when the heart contracts and pushes blood out (systolic), and the smaller value is the lowest pressure when the heart relaxes between beats (diastolic). Consider a population...

  • a. Identify situations when a blood pressure would not be measured on a client’s arm or leg. b. State the rationale for...

    a. Identify situations when a blood pressure would not be measured on a client’s arm or leg. b. State the rationale for the following nursing actions: place client’s arm at heart level, palm up palpate the brachial artery. Position cuff 2.5 cm above the brachial pulse. Center cuff above artery after inflating the cuff to find point at which brachial pulse disappears, wait 30 seconds before re-inflating the cuff inflate cuff to 30 mm Hg above palpated systolic pressure c....

  • a. Various factors can affect blood pressure. Some of these are listed below. Discuss the differences with each of these...

    a. Various factors can affect blood pressure. Some of these are listed below. Discuss the differences with each of these factors. i) age example: BP is lower in children than in adults. ii) gender: iii) race: iv) diurnal rhythm: v) weight vi) exercise vii) emotion viii) stress b. Identify situations when a blood pressure would not be measured on a client’s arm or leg. c. State the rationale for the following nursing actions: place client’s arm at heart level, palm...

  • Question 5 [10 points] A doctor at a walk-in clinic is studying high blood pressure among...

    Question 5 [10 points] A doctor at a walk-in clinic is studying high blood pressure among patients of the ages twenty to forty. According to the American Heart Association, a person has high blood pressure if their Systolic and Diastolic readings are above 130 and 39 respectively. A random sample of 10 patients revealed the following blood pressures, where the readings (x,y) correspond to (Systolic Diastolic blood pressures (179,109) (180,120) (11970) (130,85) (159,90) (110,79) (180,120) (119,70) (110,79) (159,90) Assume that...

  • A sample of blood pressure measurements is taken for a group of adults, and those values...

    A sample of blood pressure measurements is taken for a group of adults, and those values (mm Hg) are listed below. The values are matched so that 10 subjects each have a systolic and diastolic measurement. Find the coefficient of variation for each of the two samples: then compare the variation Systolic 120 130 159 96 154 121 115 135 125 119 Diastolic 80 77 74 52 90 89 56 63 70 80 The coefficient of variation for the systolic...

  • Each time your heart beats, your blood pressure first increases and then decreas...continues

    Each time your heart beats, your blood pressure first increases and then decreases as the heart rests between beats. The maximum and minimum blood pressures are calledthe systolic and diastolic pressures, respectively. Your blood pressure reading is written as systolic/diastolic. A reading of 120/80 is considered normal. A certainperson's blood pressure is modeled by the function p(t)=115 25sin (160pit) where p(t) is the pressure in mmHg, at time t measured in minutes. a) Find the period of pb) FInd the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT