Suppose I want to check if x
belongs to range 0 to 0.5. How can I do it?
No, you can't do that. range()
expects integer arguments. If you want to know if x
is inside this range try some form of this:
print 0.0 <= x <= 0.5
Be careful with your upper limit. If you use range()
it is excluded (range(0, 5)
does not include 5!)