16.01.2014 Views

Beginning Python - From Novice to Professional

Beginning Python - From Novice to Professional

Beginning Python - From Novice to Professional

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 5 ■ CONDITIONALS, LOOPS, AND SOME OTHER STATEMENTS 89<br />

More Complex Conditions<br />

That’s really all there is <strong>to</strong> know about if statements. Now let’s return <strong>to</strong> the conditions themselves,<br />

because they are the really interesting part of conditional execution.<br />

Comparison Opera<strong>to</strong>rs<br />

Perhaps the most basic opera<strong>to</strong>rs used in conditions are the comparison opera<strong>to</strong>rs. They are<br />

used (surprise, surprise) <strong>to</strong> compare things. The comparison opera<strong>to</strong>rs are summed up in<br />

Table 5-1.<br />

Table 5-1. The <strong>Python</strong> Comparison Opera<strong>to</strong>rs<br />

Expression<br />

Description<br />

x == y x equals y.<br />

x < y x is less than y.<br />

x > y x is greater than y.<br />

x >= y x is greater than or equal <strong>to</strong> y.<br />

x

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!