Well, there are actually three issues in the code:
(1) is a matter of efficiency, which woooee already raised.
status = 0
for i in range(10):
status = status + 0.1
print status
does what you wanted to do, and is cleaner to read. One payoff of this approach is that...
(2) ...in your original code, you didn't get 0.3 in the output because you left out the print statement. The lines
elif status == 0.3:
status
have the effect of evaluating, but not printing, status. And then throwing away the result, because you aren't doing anything with it.
(3) Finally, comparing floating points is a common source of bugs. Even if we worked with BCD, so that we didn't have to work about base-2 to base-10 errors, still and all, our decimal approximations would still lead to imprecision. For example, the test π == 3.14159265358979 is False.
Vega gives a very good approach to this by selecting a range. My own approach is to define a function that is in my code base:
def fuzzyequals(a,b,epsilon = 0.0001):
return abs(a-b) < epsilon
This function returns True if a is within the "halo" of b; that is, if b-epsilon < a < b+epsilon.
You can then use it like this:
...
if fuzzyequals(status,0.2): # or fuzzyequals(status, 0.2, 0.01)
print status
...
Hope that helps,
Jeff