0

how can I round this code up?

houses = int(input()) #your code goes here print(int(100.5/houses+0.5)*2) I am solving an easy community problem called Hallowen sweets and I am already desperate because that damn one skips the number I need, if the input is 3 it comes out 66 or 68, not the correct number

16th Apr 2021, 11:48 PM
Jhony
Jhony - avatar
3 Respuestas
+ 3
import math houses = int(input()) doll=2 t=float(doll/2) c=float(houses/2) p=int(math.ceil(doll*100/houses)) print(p) #Are you telling about this math.ceil function?
17th Apr 2021, 5:01 AM
Atul [Inactive]
+ 4
There are a couple of ways. #Write your own num1 = 7 num2 = 2 result = num1 // num2 print(result) #3 if num1 % num2 != 0: result += 1 print(result) #4 # or use import math.ceil() import math print(math.ceil(num1 / num2)) #4
17th Apr 2021, 12:48 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Here's a quick implementation of math.ceil() : # The integer a = 56 # a = math.ceil(a) a = int(a) + (a > int(a))
18th Apr 2021, 4:25 PM
Calvin Thomas
Calvin Thomas - avatar