Is this a valid solution for the Halloween candy problem from code coach? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Is this a valid solution for the Halloween candy problem from code coach?

I've come across this problem and when I run my code it only shows first two test cases as right. So please help me. :-) Code: houses = int(input()) d_houses = 2 prob_percent = ( d_houses / houses ) * 100 print(round(prob_percent))

18th Dec 2019, 5:25 PM
psprises
psprises - avatar
11 Answers
+ 11
First, as Dennis said read 🐍.doc & ... import math ... math.ceil(...) ...
19th Dec 2019, 10:24 AM
Janusz Bujak 🇵🇱 🇺🇦
Janusz Bujak 🇵🇱 🇺🇦 - avatar
+ 3
I can't give a direct answer to that because it's a code coach question. You might find what you need in here: https://docs.python.org/3/library/math.html
18th Dec 2019, 5:42 PM
Dennis
Dennis - avatar
+ 2
Thank you for answering my question with patience. :-)
18th Dec 2019, 5:46 PM
psprises
psprises - avatar
+ 2
I Am Nothing 😞 Don't share code in any question if there is no relationship with Question and also don't say that it's your code. It's a copy code but good thing is that you didn't remove name from code.
19th Dec 2019, 7:24 AM
A͢J
A͢J - avatar
+ 2
Shiva Prakash As you are beginner So you need to clear your basic first otherwise you can't understand anything. Do lots of practice on different types of problems to build up your logic. And good luck for contest.👍👍👍
19th Dec 2019, 7:32 AM
A͢J
A͢J - avatar
+ 1
For example lets have the number 5.3 round would truncate it to 5. According to the wording, you have to round up, so 6 would be the accepted answer, not 5.
18th Dec 2019, 5:37 PM
Dennis
Dennis - avatar
+ 1
How can I do that? (I'm new to programming, so, please don't mind)
18th Dec 2019, 5:40 PM
psprises
psprises - avatar
+ 1
🅰🅹 - ɪ'ᴍ ᴄʀɪᴍɪɴᴀʟʟʏ ɢᴏᴏᴅ! Thanks for your kind suggestion😊
19th Dec 2019, 8:42 AM
psprises
psprises - avatar
+ 1
Janusz Bujak 🇵🇱 thank you for your answer, but I already got it😅
19th Dec 2019, 12:24 PM
psprises
psprises - avatar
0
"A percentage value rounded UP to the nearest whole number."
18th Dec 2019, 5:31 PM
Dennis
Dennis - avatar
0
Dennis I didn't understand, can you please explain in detail?
18th Dec 2019, 5:34 PM
psprises
psprises - avatar