Python Forum
[split] beginner and need help with python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] beginner and need help with python
#1
hi. I need some help here as a beginner. I just need help with task 3. I don't even know where to begin.

here is the link for the assignment at GitHub. Any help would be greatful, thank you.

https://github.com/is210-spring-2017/is2...-08-warmup



Specifications

1.Work on a new line on your existing notebook


2.Using a combination of raw_input(), if, elif, and else, write a program that asks the user their blood pressure. Compare the blood pressure against the following chart and save the Status to a variable named BP_STATUS. At the end of the program, print a nice sentence with a formatting string to tell you your status and use .format() to replace the formatting string with your BP_STATUS.
Blood Pressure Readings




Hint

Don't forget that the input of raw_input is a string!

Expected Output

$ python -i task_05.py
What is your blood pressure? 120
Your status is currently: Warning!
Reply
#2
(Oct-22-2019, 06:30 PM)kalitr33 Wrote: I don't even know where to begin.

You begin with getting the user input and converting it to an integer with int(). Write that code and we can work from there.

And raw_input? That's Python 2.7. I can count the weeks until end of life for Python 2.7 without taking off my boots. If you are doing this on your own, find another tutorial using Python 3.0 or higher. If you are taking a class, be aware that your teacher is using severely outdated material.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
ok so this is what ive got so far. but I need some help putting in all the numbers that would indicate low, high, emergency.

print ("What is your blood pressure?")
BP_STATUS = input()
status = float(BP_STATUS)

if status >= 139:
   print ('Your status is currently: Warning!')
elif 110 <= status < 90:
   print ('Your status is currently: Ideal')
else: 
   print ('Your status is currently: low')
Reply
#4
Do you really think status could be SIMULTANEOUSLY greater or equal to 110 and less than 90?
(Oct-23-2019, 07:23 PM)kalitr33 Wrote: elif 110 <= status < 90:
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
That looks like you've almost got it, once you correct what buran pointed out. You numbers and output just don't match up with the table given in the assignment. You want the high end (emergency) to be like line 5, with start as the number. Then you want the middle three (high, warning and ideal) to be like line 7 (so two more elif statments), with start as the low number and end as the high number. Then the else can be low.

One trick is that if you order your if/elif statement correctly, you only need to code one side of the test:

import random

num = randint(1, 4)
if num > 3:
    word = 'Four'
elif num > 2: 
    word = 'Three'
elif num > 1:
    word = 'Two'
else:
    word = 'One'

print('{} = {}'.format(num, word))
In the first elif, I know it's not greater than three, because it must have failed the if test to get to the elif test. Therefore, if it is greater than two, I know it's three, without have to make sure it's not four.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020