Sorry to be a stickler about this point, but I find your math really hard to understand.  I think the following is equivalent, and much simpler:

if node.frequency == 0:
  freq = 0  #zero means profanity 
else:
  freq = 1 + int(node.frequency * 31) # values > 0 map the range 1 to 31