Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why wont it work

+4 votes
asked Oct 27 by sadhana pandey (170 points)
bp_rate = int(input ("what is the bp rate of your patient: "))
if bp_rate>120:
    print ("your patient has high bp rate.")
if bp_rate<80:
    print("your patient has low bp rate.")    
if bp_rate = 80 or bp_rate = 81 or bp_rate = 82 or bp_rate = 83 or bp_rate = 84 or bp_rate = 85 or bp_rate = 86 or bp_rate = 87 or bp_rate = 88 or bp_rate = 89 or bp_rate = 90 or
bp_rate = 91 or
bp_rate = 92 or bp_rate = 93 or bp_rate = 94 or bp_rate = 95 or bp_rate = 96 or bp_rate = 97 or bp_rate = 98 or
bp_rate = 99 or bp_rate = 100 or bp_rate = 101 or bp_rate = 102 or bp_rate = 103 or bp_rate = 104 or bp_rate = 105 or bp_rate = 106 or bp_rate = 107 or bp_rate = 108 or bp_rate = 109 or
bp_rate = 110 or bp_rate = 111 or bp_rate = 112 or bp_rate = 113 bp_rate = 114 or bp_rate = 115 or bp_rate = 116 or bp_rate = 117 or bp_rate = 118 or bp_rate = 119 or bp_rate = 120
    print ("your patient is fine:D.")

2 Answers

0 votes
answered Oct 27 by Vijith VT (140 points)

In your program

  • Colon (:) is missing in the last if condition.
  • backslashes(\\) required at the end of each lines

For specifying range you can make use of range function instead of typing all.

Syntax: range(start, stop, step)

Parameter:

  • start: [ optional ] start value of the sequence
  • stop: next value after the end value of the sequence
  • step: [ optional ] integer value, denoting the difference between any two numbers in the sequence.

By using range() function you can do it as follows:

bp_rate = int (input ("what is the bp rate of your patient: "))
if bp_rate > 120:
    print ("your patient has high bp rate.")
elif bp_rate < 80:
    print ("your patient has low bp rate.")
elif bp_rate in range (80, 121):
    print ("your patient is fine:D.")
else:
    print ("Wrong input.")

+1 vote
answered Oct 27 by Peter Minarik (63,140 points)

You need a colon (:) at the end of your last if. Also, you cannot break instructions into multiple lines, unless you use two backslashes (\\) at the end of lines to indicate continuation in the next line.

Also, it's much easier to express what you want like this:

bp_rate = int(input("What is the BP rate of your patient? "))
if bp_rate > 120:
    print("Your patient has high BP rate.")
elif bp_rate < 80:
    print("Your patient has low BP rate.")    
else:
    print("Your patient is fine. :D")
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...