dimanche 19 avril 2015

Only one string variable is returned out of possible 3, Python

Here is my code:



def Calc_1A(self, p1, t1, p2, t2):
a1 = math.log(p1) - math.log(p2)
b1 = t2 - t1
k1 = a1/b1
p2bar = math.log(p1) - math.log(2)
if p2bar > 16:
categ = 'SLOW'
elif p2bar < 2:
categ = 'FAST'
else:
categ = 'MODERATE'
return categ


Only 'MODERATE' is returned, even when p2hours is less than 2 or greater than 16. I know this is due to the placement of the return function but I've messed around with it and looked at other questions on this site and nothing seems to cover this problem.


The rest of my code seems to work in spite of this, but I know the category is wrong comparing it to raw data I've collected.


Aucun commentaire:

Enregistrer un commentaire