How to round floats in Python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to round floats in Python?

I try to round number and i use round() function but it didn't work,can any body help me?

24th Oct 2020, 5:59 AM
Kaleab Alemayehu
Kaleab Alemayehu - avatar
2 Answers
+ 4
Kaleab Alemayehu , it would be great when you can share your code with us here. So we see where you get stuck. Thanks!
24th Oct 2020, 7:57 AM
Lothar - avatar
+ 3
The built-in round() function will round to the nearest integer if a precision argument is not passed with the number. I.E. round(2.5452) will return 3 where round(2.5452, 2) will return 2.55 Note: decimal behavior may not be exact due to floating point arithmetic issues
24th Oct 2020, 6:38 AM
ChaoticDawg - avatar