+ 1

Code halloween (easy)

houses = int(input()) #your code goes here dollars = 2 chance = dollars / houses * 100 print(round(chance)) - The code works for the first two test, but for some reason not for the other three. The other three tests are hidden, so I can’t really find the reason as to why this code is not working.

26th Mar 2020, 4:07 PM
Matias Dure
Matias Dure - avatar
2 Antworten
+ 3
Thank you for the help, Malak! Just checked on what math.ceil() does. It rounds up any number that is bigger than its integer. So even if it should round down, like 6.1 to 6, ceil rounds it to 7. With your tip I was able to write this code that doesnt import any module and still works: houses = int(input()) #your code goes here dollar = 2 percent = (dollar/ houses) * 100 if percent > int(percent): percent = int(percent) + 1 print(int(percent))
26th Mar 2020, 4:33 PM
Matias Dure
Matias Dure - avatar