0

Coach code, Halloween candy

Please what is wrong with my code? I got 2/5 houses = int(input()) #your code goes here def perc(x): if x>= 3: y = (2/x) * 100 y = round(y, ) return y print(perc(houses))

4th Feb 2020, 2:12 PM
Ifeanyi Kalu
Ifeanyi Kalu - avatar
6 Réponses
+ 1
Ifeanyi Kalu Yeah I just solved it myself. It says "rounded UP to the nearest whole number" so instead of math.floor(), use y = math.ceil(y). That ought to work. And also the input is always >= 3 so that part is unnecessary in your code. In fact, in addition to the import math and input lines, your code can just be summed up to just one more line:- print(math.ceil((2 / houses) * 100))
5th Feb 2020, 6:16 PM
Sofonias
Sofonias - avatar
0
Maybe it's your round function. Have you tried using math.floor()?
4th Feb 2020, 3:14 PM
Sofonias
Sofonias - avatar
0
What do i have to import?
4th Feb 2020, 8:25 PM
Ifeanyi Kalu
Ifeanyi Kalu - avatar
0
It didn't approximate correctly.
4th Feb 2020, 8:28 PM
Ifeanyi Kalu
Ifeanyi Kalu - avatar
0
Ifeanyi Kalu add import math on the first line and then instead of the round() function, use y = math.floor(y). I hope this works for you.
5th Feb 2020, 7:53 AM
Sofonias
Sofonias - avatar
0
Sofonias it didn't work.
5th Feb 2020, 5:55 PM
Ifeanyi Kalu
Ifeanyi Kalu - avatar