+ 6
Is there any command for that?
"A percentage value rounded up to the nearest whole number" - from the Halloween candy task
11 odpowiedzi
+ 9
Quarkom replace round() with ceil(). Here is your corrected program:
import math
houses = int(input())
housesBill= 2
percentage=(100*housesBill)/(houses)
print(math.ceil(percentage))
+ 6
Quarkom round() does not work here because it sometimes rounds down. Since the task is to always round up, you should use the ceil() function from the math library.
+ 4
Yeah, the round() function. For example:
print(round(80.01720))
Output:
80
Other example:
print(round(90.100, 2))
Output:
90.1
Because:
The second parameter is the amount after of . and if you don't put a second parameter, is a total number.
Any doubt ask me.
+ 2
Tysm
+ 1
Yes, round function. Sample:
x = round(5.765)
x will be 6
+ 1
Ty, however sololearn still won't accept my code even if code shows good answers and my output is the same as expected one. Here is the code:
+ 1
houses = int(input())
housesBill= 2
percentage=(100*housesBill)/(houses)
print(round(percentage))
+ 1
Brian could u pls write how that command should look like with an input integer?
+ 1
Brian
X=int(input())
print(ceil(X))
?
+ 1
Thanks guys, topic ended.
0
ت