def fib(n): '''Return the nth fibonacci number.''' if n == 0 or n == 1: return 1 else: return fib(n - 1) + fib(n - 2) def strlen(some_string): '''Recursively return the length of some_string.''' if some_string == '': return 0 else: return 1 + strlen(some_string[1:]) def reverse(s): '''Return the string s in reverse.''' if s == '': return '' else: return reverse(s[1:]) + s[0] def is_palindrome(s): '''Return whether s is a palindrome.''' if len(s) <= 1: return True elif s[0] != s[-1]: return False else: # recursive case return is_palindrome(s[1:-1]) def contains_pattern(text, pattern): '''Return whether pattern appears somewhere in text.''' if text.startswith(pattern): return True elif len(pattern) > len(text): return False else: return contains_pattern(text[1:], pattern)