Sunday, 24 September 2017

Round float in Python





I have a problem with float in Python...



I have this in a variable:



i = 9.600000000000001



And I would transform in this:



i = 9.60000


with five numbers after the decimal point and rounded.


Answer



>>> format(9.60000001,'.5f')                                                                                                            

'9.60000'
>>>

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...