1==1
True
1==2
False
You can do the same with strings not just numbers. If you want to see if they are not equal, the symbol is != .
1 !=0
True
When you have strings, you can access all methods that a string normally has. The example in the book is good:
gourd = "Calabash"
gourd.lower()
"calabash"
gourd.uppper()
"CALABASH"
Lower makes it lower case while Upper makes it all uppercase.
The word not provides the opposite of the truth value that follows it. The not operation applies to any test that will result in a true or false outcome.
not 9 > 2
False
Now we are onto IF statements. This if statement will allow you to get decisions made.
if 5 > 8:
print "No, it is not"
print "Yes, it is"
You can place the if statements within tests.
No comments:
Post a Comment