Output a Number to 2 Decimal Points

I should remember how to do this.

So you have 3.141592653 in a variable and you want to output up to the 2 decimal points. Here is how you can do it.

a = 3.141592653

The code above returns string. If you want to convert it to an actual float value, you can surround it with float.

Here is a Python3 way. This is cleaner.


Leave a Reply

Your email address will not be published.