title: Rounding a number while using string formatting in python
body: <p>I'm wondering how to round a number in python while using string formatting. In my code, I used %r instead of %d, beacuse %d prints an interger. How do I round the numbers while using %r? I would like to have my numbers rounded to two decimal places.</p>
  
  <pre><code>def new_formula(value):
      payment = value * 9.00
      tips = payment/.29
      earned = payment + tips
      return payment, tips, earned
  
  name = "Nate"
  hours = 7.5
  
  print "%s worked %r hours." % (name, hours)
  print """He was paid %r dollars and made %r dollars in tips.
  At the end of the day he earned %r dollars.""" % new_formula(hours)
  </code></pre>