15.04.2013 Views

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

largest factor of 14 is 7<br />

largest factor of 15 is 5<br />

largest factor of 16 is 8<br />

17 is prime<br />

largest factor of 18 is 9<br />

19 is prime<br />

largest factor of 20 is 10<br />

Likewise, a for loop can have a post-processing else. It operates exactly the same way as for a while<br />

loop. As long as the for loop exits normally (not via break), the else clause will be executed. We saw<br />

such an example in Section 8.5.3.<br />

Table 8.1 summarizes with which conditional or looping statements auxiliary statements can be used.<br />

Table 8.1. Auxiliary Statements to<br />

Loops and Conditionals<br />

Loops and Conditionals<br />

Auxiliary Statements if while for<br />

elif •<br />

else • • •<br />

break • •<br />

continue • •<br />

pass [a] • • •<br />

[a] pass is valid anywhere a suite (single or multiple statements) is required (also includes elif, else, class, def, TRy,<br />

except, finally).

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

Saved successfully!

Ooh no, something went wrong!