[Tutor] If elif not working in comparison

gerardo arnaez garnaez at gmail.com
Mon Mar 28 09:11:13 CEST 2005


Hi all,
I am trying to get a value dependant on initial vlaue inputed
Depending on the value, I want the functiont to return a percentage
For some reason, It seems to skip the first if state and just print
out the 1st elif
not sure what is going.
also, is there a cleaner way to write this?
-=-------------------------


#! /usr/bin/env python
'''
Calulate the percent increase in dose given an INR value.
'''

def INRadjust(x):
    if x < 1:
        return .15
    elif x < 1.5:
        return .12
    elif x < 1.75:
        return .1
    elif x < 1.9:
        return .05
    elif x < 3.1:
        return 0
    elif x < 4.1:
        return -.1
    elif x < 5.1:
        return -.2
    elif x < 6.1:
        return -.25
    elif x < 7.1:
        return -.3
    else:
        print "Notify Doctor"


More information about the Tutor mailing list