/* */

Wednesday 23 March 2011

Comparisons

Comparisons are boolean operations and utilise operators to return a true or false answer (o or 1).

x=y= [1,2,3]
z= [1,2,3]
x==y
True
x==z
True
x is y
True
x is z
Flase

The == simply means 'same value' - Slight differeation from a single =, we use this to assign a value to a variable, we use the double == to test whether two values are equal.
The is operator tests if they are the same object - in the above example x is not the same object as z (although they share the same value). Lists can be equal but not identicle.

No comments:

Post a Comment