Oh well since a few solutions have already been posted I thought I
might add another, just so you at the very least you have to do some
work making up your mind which one to choose. Using an incremental
approach just to be different ...
from decimal import Decimal
normal = Decimal('0.04')
over = Decimal('1.40)
def calcStopPay (stops) :
pay = Decimal('0.00')
while stops :
incr = normal if stops < 23 else over
pay += incr
stops -= 1
return pay
#testing:
for x in range(50) :
print "Stop pay for %s stops: $%s" % (x, calcStopPay(x))
--
http://mail.python.org/mailman/listinfo/python-list