Kent Johnson wrote:
> Johan Geldenhuys wrote:
>   
>> Hi all,
>>  
>> I have a value that ranges between 48.01 and 48.57. a Float value in 
>> other words.
>>  
>> I want to look at changes in the value. If my normal range is between 
>> 48.35 and 48.45, how will I identify the value below 48.35 and above 48.45?
>>  
>> Something I tried was:
>>  
>> for a in range(48.35, 48.45):
>>     print a
>>  
>> It gives me a value of 100.
>>  
>> Is it possible to get a range of a float value?
>>     
>
> You can't generate all the float values in a range. (OK, you probably 
> could, but it would not be practical or useful.) You can test for a 
> value in a range, e.g.
> if 48.35 <= a <= 48.45:
>   
Kent:
Why does this work?
In C++ this would go from

if (48.35 <= a <= 48.45)

to (assuming the right condition is met)

if (48.35 <= true)

because it evaluates these things right to left, doesn't it?
does python treat chained comparisons differently than C++ or is C++ 
behaving differently than I think it does?
Thanks for your help,
-Luke
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to