Lecture Notes on 4 April 2014 # function to obtain the nth Fibonacci term def fib (n): if (n == 0) or (n == 1): return n else: return fib (n - 1) + fib (n - 2) # function that returns True if the first or last element is a 6 def first_last6 (nums): return (nums[0] == 6) or (nums[-1] == 6) # function that returns True if the first and last elements are equal def same_first_last (nums): if (len(nums) == 0): return False else: return nums[0] == nums[-1]