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
3 Réponses
+ 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?
+ 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
0
Here's a quick implementation of math.ceil() :
# The integer
a = 56
# a = math.ceil(a)
a = int(a) + (a > int(a))