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!)