Unit Testing
Download unit supplement (zip file) for exercises based on the Python doctest module. These exercises contain test cases which have function calls and expected responses, but are missing the definitions of the functions. The task of each exercise is to edit the programs and supply the missing functions. Within the Unit-Supplement directory, exercises are categorized into subdirectories:
The subdirectory Basic has the simplest exercises, which can be solved just by defining functions with expressions and operators. with expressions.
The subdirectory Condition also has basic exercises, but needing conditional logic (function definition, expressions, and if/else statements).
The Slice subdirectory uses slice operations or more advanced sequence methods.
The Iteration subdirectory has the bulk of the exercises. These exercises are intended for practice writing comprehension expressions, or loops, or recursion. In some cases, these exercises need mutation to a function argument (typically done by assignment or by using a mutating method on a sequence).
In each program, there are two lines of the form #----------- which Python will treat as comments and ignore. Please put your definition of the needed function between these two lines. And remember, you can define a function that takes advantage of Python's built-in functions and methods, unless the instructions in the program comments recommend against this. Also, you can write more than one function to solve a problem. For example, if the needed function is F(x), you could define G(a,b) and then in the definition of F, you could call (a,b) in an expression inside the body of F.
Download Teken (zip file) to get the drawing module used in the book. There is a README file, some demonstration programs, though it might need some modifications to for it all to work. Though much of teken is built-in to stepper, this downloaded teken module draws using HTML5 through a webbrowser.