# Outline for February 12, 2018

1. Comments on homework: on the whole, quite good!
1. Make your program as simple as possible
2. Comments should not repeat the code, but explain at a higher level what is being done and why
3. Put a comment at the head of each function saying what the function does, what (if anything) it returns, and what its parameters mean
4. Indent your comments to be in line with the code to which it refers
2. Recursion
1. n factorial [nfact.py]
3. Thinking recursively [recfun.py]
1. First: think of the recursive case (write the problem in terms of something involving a smaller instance of the problem)
2. Next: think of base case (when to stop)
3. Example: Find the length of a string
4. Example: Does the string only have alphabetic characters in it?
5. Example: Find the maximum element of a list
6. Example: Construct a string from a list of strings
7. Example: Reverse a string
4. Recursion
1. Palindromes [palindrome.py]
2. Fibonacci numbers [rfib.py]
3. Sum of digits [sumdigits.py]
5. isinstance(obj,type) function
1. type is bool, float, int, list, str, tuple
2. Nested lists: is an item in a list? [isinlist.py]

 Matt Bishop Department of Computer Science University of California at Davis Davis, CA 95616-8562 USA