0
help with simple python Code
hello everyone. I am tryign the challenges in the app. I've written this code for the problem that asks me to output a percentage value (integer number) rounded up. The problem says that one house are giving toothbrushes, two houses are giving dollar bills and the rest are giving candy, the value that I need is the chance of pulling out a dollar bill from the bag. I dont know what is wrong and Sololearn hides the 3 last tests which are the ones that are giving me problems. I don't know if I explained myself well, here is the code: houses = int(input()) dollar = 2/houses perc = round(dollar*100) print(perc)
3 odpowiedzi
+ 2
The round() function won't work, because it may round the result down. You can use math.ceil() instead, which always rounds the result up. To do that, all you have to do is:
import math
math.ceil(#some decimal number)
+ 2
The task says to round up, so try the ceil() function instead of round()
+ 1
thank you both, I wasn't aware of that function