Someone came with this example to me (python2):
num = int(input("num"))
den = int(input("den"))
quot = 0
rest = den
i = num
for i in range(i,i>den, -den):
quot = quot + 1
rest = i - den
print quot
print rest
The code runs fine, does what it needs to be doing, and doesn't produce errors.
I don't understand why. To me, range() requires a lower and an upper limit, and to me, i would be the lower value, while i>den should evaluate to a boolean?
The context is a tutorial function which implements division with a for loop.
iandnum).Trueevaluates to1andFalseto0. But it certainly wouldn't behave like a C-like'sforstatement. It's just setting the stop point of iteration to either0or1.