Page 6 - Python for Everybody
P. 6
vi
CONTENTS
3
2.10 Askingtheuserforinput ....................... 25 2.11 Comments ............................... 26 2.12 Choosingmnemonicvariablenames ................. 27 2.13 Debugging ............................... 28 2.14 Glossary................................. 29 2.15 Exercises ................................ 30
Conditional execution 31
3.1 Booleanexpressions ........................... 31
3.2 Logicaloperators............................ 32
3.3 Conditionalexecution ......................... 32
3.4 Alternativeexecution ......................... 33
3.5 Chainedconditionals.......................... 34
3.6 Nestedconditionals .......................... 35
3.7 Catchingexceptionsusingtryandexcept . . . . . . . . . . . . . . 36
3.8 Short-circuit evaluation of logical expressions . . . . . . . . . . . . 38
3.9 Debugging ............................... 39
3.10 Glossary................................. 39
3.11 Exercises ................................ 40
4 Functions 43
4.1 Functioncalls.............................. 43
4.2 Built-infunctions ........................... 43
4.3 Typeconversionfunctions....................... 44
4.4 Mathfunctions............................. 45
4.5 Randomnumbers ........................... 46
4.6 Addingnewfunctions ......................... 47
4.7 Definitionsanduses .......................... 48
4.8 Flowofexecution ........................... 49
4.9 Parametersandarguments ...................... 49
4.10 Fruitfulfunctionsandvoidfunctions.................. 51
4.11 Whyfunctions?............................. 52
4.12 Debugging ............................... 52
4.13 Glossary................................. 53
4.14 Exercises ................................ 54