function round in python

From round() documentation :

Return number rounded to ndigits precision after the decimal point. If
ndigits is omitted or is None, it returns the nearest integer to its

Rounding an integer will always return the integer you passed to it, no matter what :

round(42, 50)

The second parameter is used to ask for a certain number of digit after the dot for floats.


Cause 0 digit after dot is asked.

round(1.2, 1)

Cause 1 digit after dot is asked.


2 digits are asked, but the floating number gave in parameter has only one digit.

In your case res1 and res are highly dependent of self.inst self.elt and so we cannot help you if you are not more specific. I suggest you write your code with one line by operation and check the results at each steps. I think your problem is not coming from the round() function, but the operations inside it.

By the way nobody will figure out what you try to achieve with those variable names.

Browse More Popular Posts

Leave a Comment