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))
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))
0
Maybe it's your round function. Have you tried using math.floor()?
0
What do i have to import?
0
It didn't approximate correctly.
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.
0
Sofonias it didn't work.