16 ответов
+ 6
The tests are a bit weird.
There were several reports about solutions that shouldn't work but did. I encountered a few myself.
For example here:
https://www.sololearn.com/discuss/2116672/?ref=app
+ 20
In C++ both "ceil()" and "round()" Worked, they pass all 5 tests... How Come ??? 😐😐
+ 17
In the solution of "Paint costs" in code coaching.. Did you use round(). I tried multiple times and it fails. Can u help me with that plz ??
+ 15
Ooowh! Thank you for that. I Got this Now. 👍
+ 14
Got it! I tried math.ceil() ... Thank you!
😐 in java and c++ that round() function works. so is round() used to round up in c++ and java. ?
+ 11
That's exactly what the round function does.
round(5.6) -> 6
round(4.4) -> 4
+ 6
It is impossible to be fault check your dot.. maybe you used comma
+ 5
In paint cost you need to "round up" to the nearest whole number.
+ 5
Either you can use math.ceil() you can use round() to use round the syntax is
round (float value to be rounded,no of decimal places upto which it would be rounded)
+ 5
But i will prefer you round over ceil
+ 4
In C++, you can get ceil from <cmath>. In Java, it's Math.ceil.
+ 4
In order to round up the value, you have to use round() function
For instance
decimal_no = 343.5567
print(round(decimal_no)
print(round(decimal_no, 2) # 2 means the no. gets rounded to two digits
Here output:
344
343.56
More info:
Like some other suggested ceil() and floor(), let me add some more points. In order to use those functions the math library is used.
ceil(x) - It returns the highest value of x
floor(x) - It returns the lowest value of x
from math import ceil, floor # import math <- This could also be used but use math.func()
dec_no = 454.45343
print(ceil(dec_no))
print(floor(dec_no))
Output:
455
454
+ 4
You can import math
And then use math.ceil(x)
(Return the ceiling of x, the smallest integer greater than or equal to x.)
+ 3
Ona nixon kowero
+ 2
U can either use ceil() to round off to the up number eg. 3.666 to 4.0 or use floor() to round off to the lower number eg. 3.66 to 3
+ 2
👍