12.07.2015 Views

Think Python - Denison University

Think Python - Denison University

Think Python - Denison University

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.

xiiContents3 Functions 173.1 Function calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.2 Type conversion functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.3 Math functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.4 Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.5 Adding new functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.6 Definitions and uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.7 Flow of execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.8 Parameters and arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.9 Variables and parameters arelocal . . . . . . . . . . . . . . . . . . . . . . . . . 223.10 Stack diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.11 Fruitful functions and void functions . . . . . . . . . . . . . . . . . . . . . . . . 243.12 Why functions? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.13 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.14 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.15 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 Case study: interface design 294.1 TurtleWorld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.2 Simple repetition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.4 Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.5 Generalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.6 Interface design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.7 Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344.8 A development plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354.9 docstring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354.10 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354.11 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364.12 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

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

Saved successfully!

Ooh no, something went wrong!