- 3
Code Coach Problem(Bug Found)
This is a problem from the Code Coach.The Name of the problem is "Paint Costs"(Easy Level) While solving it says that 2 hidden test cases failed but it sees right to me.I think there's no bug in it.Can anybody plz tellcme why code coach is saying that two test cases failed??? https://code.sololearn.com/cTq2RWHUTq79/?ref=app
11 Réponses
+ 2
Wahid Kabir
You have to use ceil() function to get the nearest integer...
First import math
Then..,
use ceil() function:
z=math.ceil(y*(10/100))
+ 4
Your problem is here
z=int(y*(10/100))
You need to round up the calculation
+ 2
Indira if you use ceil(), it'll jump to the next integer. You have to use round() to get the nearest.
from math import *
x = int(input())
y = (x * 5)+40
print (round(y * 1.1))
+ 2
Indira Check now... It was my typing mistake 😅....
It's working correctly now...
Check it out now
+ 2
That's what I was telling the whole time Indira
+ 1
Thank you Indira for helping me
+ 1
Hind Biswas
Round() is used for round down to the nearest whole number whereas ceil() is used for round up to the nearest whole number...
+ 1
Indira floor() is used to round down.... While round() is used to get the nearest value....
Check out the following code, you'll understand:-
https://code.sololearn.com/c9N7Hl3rzq9C/?ref=app
0
Wahid Kabir
You're welcome..👍:)
0
Hind Biswas
Just look at the 3rd example of round...
0
Hind Biswas
Look.. round() will give u round down when the number after decimal is less than 5.. otherwise it will give u round up...
But ceil() always give u round up.