OK, this what I wanted:
 
I have a value: a = 48.41
 
My lowValue is: lowValue = 48.35
My highValue is : highvalue = 48.45
 
if a <= lowValue:
    print 'value below limit'
 
if a >= highValue:
    print value above limit'
 
I though that it could be possible to have a range between 48.35 and 48.45
that could have a step of 0.1
 
This works fine with normal intgers:
 
>>> def lookAtRange(a):
...     if a in range(40, 110, 10):        #Would like to have: if a in
range(48.35, 48.45, 0.1):
...         print 'In limits'
...     else:
...         print 'Out of limits'
...         
>>> lookAtRange(40)
In limits
>>> lookAtRange(50)
In limits
>>> 
>>> lookAtRange(20)
Out of limits
>>> 
>>> lookAtRange(120)
Out of limits
>>> 
 
Johan
 

   _____  

From: Andre Engels [mailto:[EMAIL PROTECTED] 
Sent: 08 February 2007 07:17 PM
To: [EMAIL PROTECTED]
Cc: [email protected]
Subject: Re: [Tutor] Range of float value


2007/2/8, Johan Geldenhuys <HYPERLINK
"mailto:[EMAIL PROTECTED]"[EMAIL PROTECTED]>: 

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?


It depends. What would you like it to be? All numbers in that range? They're
uncountably infinite, so no way we could ever get that out of the computer.
All actual float values? Depends too much on the implementation of the
specific machine you're working on to be workable. 

Identifying values below 48.35 and above 48.45 is simply done by:
if value < 48.35 or value > 48.45 then...

No need to first create the range of values

-- 
Andre Engels, HYPERLINK "mailto:[EMAIL PROTECTED]"[EMAIL PROTECTED]
ICQ: 6260644  --  Skype: a_engels 


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.30/674 - Release Date: 2007/02/07
03:33 PM



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.30/674 - Release Date: 2007/02/07
03:33 PM
 
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to