0
Hi. I tried to answer this but, in Halloween Candy (Python),it is wrong. Can you help me?
houses = int(input()) chance = ((2/houses)*100) round = round(chance) print(round) I am right for the first two results but the wrong ones are locked. Can you tell me what's wrong here?
3 ответов
+ 5
https://code.sololearn.com/cjlF96uKlN1U/?ref=app
Use ceil operation instead of round
+ 5
have another look at the task description: it ask us to round ***up***
+ 1
If you don't want to use the imported module you can also round up this way (that's what I did because I'm a newbie and I've not yet come across any lesson on importing anything):
houses = int(input())
bills = (2 / houses) * 100
dec = bills - int(bills)
if dec > 0:
bills += 1
print(int(bills))
When you subtract " (int)Bills" from "bills" you're left with only the decimals, so now all you have to do is add "1" to the solution, if the decimals are more than zero.
Hope that helps!