+ 1

Is this well coded?

I had to round up a number in python, and I came up with this idea: num = float(input)) print(int(num + 0.99)) This adds 0.99 to the number, so that it will always be 1 more unit than the output, or the output itself. Then I remove the decimals and end up with the desired number. My problem is that I don't know if there is a better way to do it. Could someone help me? Thanks for reading.

31st Aug 2020, 2:15 PM
Soul
2 Respostas
+ 1
You can directly use ceil function.. Do you want to write your own ceil function..?
31st Aug 2020, 2:46 PM
Jayakrishna 🇮🇳
+ 1
Oh thx, I'm new to python and I didn't know about that function 😂
31st Aug 2020, 2:48 PM
Soul