Decimal places not giving expected output

In given code, kindly point the error. It is not giving precision upto 3 decimals.

use this print ( round (num, precision_upto )) so here it will be something like print(round(num,3))

Yes that can be done. But bcoz the loop is running 3 times. So it should have 3 decimal digits only. Why rest are there ? Just like sir used for loop and achieved it.

@anuj_it
if you will check the same code with python 2.7 It is giving correct output till 3 decimal digits.
There are some changes in python3 for default formatting decimal places in floating numbers.

You can read about it more on google https://docs.python.org/3/tutorial/floatingpoint.html

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.