+ 2
Halloween Candy Problem
Hello, all. I tried to make it without import Math, however, I am stuck. Could you tell me what is the problem? houses = int(input()) before_round = ((2/houses)*100) remain=before_round%1 if remain<0.5: pass else: before_round+=1 print(round(before_round))
10 Answers
+ 3
Try this, (should work):
houses = int(input())
before_round = 2/houses*100
remain=before_round%1
if 0!=remain<0.5:
before_round+=1
print(round(before_round))
Although there is a much shorter way đ
+ 4
Earl , there is nothing to be confused about, it is only important to know that there are different ways of rounding and they must be taken into account when compiling programs.âșïž
+ 3
You can round up without the math module, but why do it if you don't have to?
https://code.sololearn.com/cmRYOBX43VRO/?ref=app
+ 3
Earl, the assignment clearly states that the output should be rounded to the nearest whole number, so "ceil" has absolutely nothing to do with it.
+ 2
# Hi! You can try this:
ch = 2/int(input()) * 100
print(int(ch + 1 if ch > int(ch) else ch))
+ 2
Simon Sauter đł Seriously?
Are you sure?đ€
+ 1
Solo rounded *up*:
"Output Format
A percentage value rounded up to the nearest whole number."
0
Thank you all! Yeah I think I need to use ceil...
0
I copied and pasted it directly from the description.
Admittedly, saying both "rounded up" and "nearest whole number" is somewhat unfortunate and potentially confusing.
0
Sorry, I was confused too. The output should be 'rounded up' đ€Ł