+ 6

Is there any command for that?

"A percentage value rounded up to the nearest whole number" - from the Halloween candy task

5th Nov 2021, 1:18 PM
Quarkom
11 Respuestas
+ 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))
5th Nov 2021, 2:24 PM
Brian
Brian - avatar
+ 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.
5th Nov 2021, 1:29 PM
Brian
Brian - avatar
+ 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.
6th Nov 2021, 6:51 PM
CGO!
CGO! - avatar
+ 2
Tysm
5th Nov 2021, 2:25 PM
Quarkom
+ 1
Yes, round function. Sample: x = round(5.765) x will be 6
5th Nov 2021, 1:23 PM
Lütfi Burak ATMACA
Lütfi Burak ATMACA - avatar
+ 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:
5th Nov 2021, 1:32 PM
Quarkom
+ 1
houses = int(input()) housesBill= 2 percentage=(100*housesBill)/(houses) print(round(percentage))
5th Nov 2021, 1:32 PM
Quarkom
+ 1
Brian could u pls write how that command should look like with an input integer?
5th Nov 2021, 2:16 PM
Quarkom
+ 1
Brian X=int(input()) print(ceil(X)) ?
5th Nov 2021, 2:17 PM
Quarkom
+ 1
Thanks guys, topic ended.
5th Nov 2021, 2:30 PM
Quarkom
0
ت
7th Nov 2021, 8:50 AM
basel alalawi