0

How do I round up following code? It's Halloween Candy challenge easy.

def prob(x): res = int(2/x*100) print(res) prob(int(input()))

25th Sep 2021, 10:08 AM
Steven E. Carpenter
Steven E. Carpenter - avatar
4 ответов
+ 6
Hacker Badshah it is round "up" (math.ceil instead of round )
25th Sep 2021, 10:15 AM
Abhay
Abhay - avatar
+ 2
"""Then you have to use math module For rounding up Like this:""" import math houses = int(input()) chance = ((2/houses)*100) print(math.ceil(chance))
25th Sep 2021, 10:18 AM
Hacker Badshah
Hacker Badshah - avatar
0
Then 66.6666 sounds down to 66, not 67.
25th Sep 2021, 10:14 AM
Steven E. Carpenter
Steven E. Carpenter - avatar
0
The math.ceil worked but only after I changed the first integer call to a float.
25th Sep 2021, 7:09 PM
Steven E. Carpenter
Steven E. Carpenter - avatar