Homework 16: Recursion

Assigned
Friday, November 18, 2016
Due
11 p.m., Tuesday, November 29, 2016
Summary
In this assignment, you will practice writing recursive functions.
Collaboration
Do this short assignment on your own. (But do ask for help if you get stuck!)
Submitting
Submit a Python module using the online turnin form. See below.
Scoring
8 points

Assignment

Create a file named recursion.py. In that file, implement and test the following two functions:
  1. palindrome(a_string) Is an extension of the book’s palindrome function. It should take a string and return True or False, depending on whether or not the string is a palindrome. However, it should ignore capitalization, spaces, punctuation, and any characters that are not letters. You may NOT use any built-in string methods for this problem. You may, of course, use string indexing using square brackets.

    For example:

    assert palindrome("Was it a car or a cat I saw?")
    assert palindrome("Rise to vote, sir!")
    assert palindrome("A man, a plan, a canal -- Panama!")
    assert palindrome("Doc, note: I dissent. A fast never prevents a fatness. I diet on cod.")
  2. licensePlates(length, letters, numbers) is specified in exercise 10.2.12 in our textbook.
Be sure to solve these problems using recursion.

Above & beyond

Hungry for more? For extra credit implement one of the additional fractals described in the section 10.1 exercises. Or try exercise 2 or 10 from this online textbook.

Submitting your work

Submit recursion.py using the online turnin form.

Good luck, and have fun!


Janet Davis (davisj@whitman.edu)

Created November 18, 2016
Thanks to Andy Exley for the draft writeup. Thanks to Wikipedia for examples of palindromes. Last revised November 18, 2016, 08:23:17 AM PST
CC-BY-NC-SA This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.