Reputation: 1017
I am new to python. I was trying to solve a matrix problem in which I have to use exit condition in loop for example if column and row of matrix is 3 or 4 then i want to run the loop 2 times and if col and row is 5 or 6 then it run 3 times.
>>> math.ceil(1.5)
2.0
>>> i=3
>>> math.ceil(i/2)
1.0
Upvotes: 1
Views: 2503
Reputation: 45
try this first:
i=3/2
print i
j=float(3)/2
print j
print math.ceil(j)
you should see
1
1.5
2.0
the way python deals with integer division is taking the lower bound.
Reference:
http://docs.python.org/2/reference/expressions.html
Upvotes: 0