• Register
110 points
5

Today we will see in our website kodlogs how in python we write decimal numbers in a round. Most of the students I have seen find it very difficult to round decimal numbers. This also happened to me when  I used to go to my institute to learn programming. I had a hard time understanding floating and decimal. In fact, it is a very simple method. I will explain it to you in very simple words. Remember one method.  If you want to omit up to 2 you want to omit the third value. You must check whether the value of 3 rd is less than or greater than five. If it is greater than 5 then 1 is added to the second. If 4 digits round off.  It is very important to check the last value. If the last digit is greater than 5 then 1 is added. If it is 4 then we will not add anything. Let's do some practical and try to understand these functions further.

>>>0.356
O/p
0.36

>>>0.625
O/P
0.63

 

110 points
5