0

What's the easiest way on how to approximate a decimal number to the nearest integer in Python.

I tried using Ceil and Floor functions from the Math module which seem to work in some cases thus finding the best flawless way to accomplish the task.

13th Dec 2020, 10:01 PM
Maarifa Shaib Maarifa
Maarifa Shaib Maarifa - avatar
2 odpowiedzi
+ 5
I like Numpy, there is probably a better way, but this is an easy way https://code.sololearn.com/cXr6Putl688g/?ref=app
13th Dec 2020, 10:27 PM
Steven M
Steven M - avatar
0
number = 3.14 print(round (number) ) ?
14th Dec 2020, 8:27 AM
Kevin ★