0

Python - exercise

Hi, i have a question regarding Halloween Candy, my code works for the first two tests but not for the rest. Problem is I can't see the output for the rest so I can't figure out what's wrong or what's expected, that's pretty badly designed no? Here is the code that I wrote : houses = int(input()) #your code goes here nbr = 2 / (houses) print(round(nbr * 100)) Could someone tell me what's wrong with it?

29th Jan 2020, 4:14 AM
Hoodelali
5 odpowiedzi
+ 3
You are just rounding the number. The question asks you to round it up to the next integer. That is to perform the ceil function, not round. import math do math.ceil() instead of round()
29th Jan 2020, 4:29 AM
Tejaswi Hegde
Tejaswi Hegde - avatar
+ 1
Oh I didn't think we could use other libraries. I also didn't see written anywhere that we are supposed to round it up to the next int. Perhaps it'd be good to add that info. The text is misleading as it says round to the nearest int In any case thanks a lot for your help!
29th Jan 2020, 4:33 AM
Hoodelali
0
It does say to round it up to the next whole number in the output section.
29th Jan 2020, 4:48 AM
Tejaswi Hegde
Tejaswi Hegde - avatar
0
"Output Format A percentage value rounded up to the nearest whole number. " The nearest whole number of 3.2 is 3 ;)
29th Jan 2020, 6:13 AM
Hoodelali
0
We'll take an example to understand the round() method: round(3.2) returns 3 round(3.4) returns 3 round(3.5) returns 4 So if the number after the point is less than five, the program will take only the integer of the whole number. And if it's equals or bigger than five, the program will return the integer + 1
30th Jan 2020, 11:49 AM
Ahmed Amine Doudech
Ahmed Amine Doudech - avatar