+ 1
Float and interger
Example: number=1/3 print(number) Output: 0.3333333333333 Expect output: 1 So when there is a decimal, I want the number to add one without showing the decimal after it. How do I do that?
8 ответов
+ 5
from math import ceil
print(ceil(1/3)) # 1
+ 3
I don't know if people here are downvoting for personal reasons but the code provided by Ashwini is also a correct answer.
+ 2
Ashwini your code is also correct.
+ 1
Thanks you
+ 1
Ashwini I tried your code, but I got 0 instead of 1.
+ 1
+ 1
Thank you, @Sonic sir.
- 1
without using the library.
Print(round(number+0.5))