def f(volume,price): if volume > 40000: return float('{:.2f}'.format(price * .06)) discount = volume // 10000 + 2 return float('{:.2f}'.format(price / 100 * discount)) print(f(20000, 20457))