Code Coach Problem(Bug Found) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 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

18th Jul 2020, 3:38 AM
Wahid Kabir
Wahid Kabir - avatar
11 Answers
+ 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))
18th Jul 2020, 3:59 AM
Indira
Indira - avatar
+ 4
Your problem is here z=int(y*(10/100)) You need to round up the calculation
18th Jul 2020, 3:50 AM
ChaoticDawg
ChaoticDawg - avatar
+ 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))
31st Aug 2020, 8:42 AM
Hind Biswas
Hind Biswas - avatar
+ 2
Indira Check now... It was my typing mistake 😅.... It's working correctly now... Check it out now
1st Sep 2020, 8:50 AM
Hind Biswas
Hind Biswas - avatar
+ 2
That's what I was telling the whole time Indira
1st Sep 2020, 2:52 PM
Hind Biswas
Hind Biswas - avatar
+ 1
Thank you Indira for helping me
18th Jul 2020, 6:00 AM
Wahid Kabir
Wahid Kabir - avatar
+ 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...
31st Aug 2020, 9:13 AM
Indira
Indira - avatar
+ 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
31st Aug 2020, 4:23 PM
Hind Biswas
Hind Biswas - avatar
0
Wahid Kabir You're welcome..👍:)
18th Jul 2020, 6:03 AM
Indira
Indira - avatar
0
Hind Biswas Just look at the 3rd example of round...
1st Sep 2020, 2:11 AM
Indira
Indira - avatar
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.
1st Sep 2020, 12:05 PM
Indira
Indira - avatar