""" Authors: TODO: Your names here Consulted: Date: 2024-11-19 Purpose: Extra fruitful recursion practice. NOTE: This file does NOT contain optimism tests, nor is there a separate testing file. YOU are responsible for testing these functions, and you should fill in the docstrings with examples BEFORE you start to write the code for each. If you use 'doctest' style examples, the code at the end of the file will check them for you (see the comment down there). """ def sumOfEvens(n): """ Returns the sum of all even numbers up to and including n (assuming n is even, or up to n - 1 if n is odd). For example: (Fill in your examples here) """ pass # TODO: Write me def isPalindrome(word): """ Returns True if the word is a palindrome and False if not. Counts the empty string as a palindrome. For example: (Fill in your examples here) """ pass # TODO: Write me def onlyLarger(numbers, threshold): """ Returns a new list of numbers that includes only the numbers in the given list which are greater than or equal to the given threshold. (Fill in your examples here) """ pass # TODO: Write me def logarithm(n, base): """ Returns the (integer) logarithm of n in the given base, which is the number of times that n can be divided by the base before the result is less than 1 (we won't worry about negative values and will just return 0 for any numbers that are already less than 1). For example, if n is 10 and the base is 2, then the result will be 3, because 10 / 2 is 5, 5 / 2 is 2.5, and 2.5 / 2 is 1.25, but 1.25 / 2 is less than 1. We'll assume that the base is a positive integer greater than 1. More examples: (Fill in your examples here) 24 """ pass # TODO: Write me def countSentences(text): """ Returns the number of sentence-ending punctuation marks ('.', '!', or '?') within the given piece of text. Doesn't always work perfectly. Hint: you do NOT have to break the text up into words. For example: (Fill in your examples here) """ pass # TODO: Write me # These lines will test any 'doctest' examples you include in docstrings # above. A 'doctest' example starts with '>>>' and some code, and then # shows the result for that code on the next line down. For example: # >>> sumOfEvens(3) # 2 # This would be a valid doctest for sumOfEvens (although it needs to # appear in a function's docstring, not in a comment). # If any of your doctests are incorrect, these lines of code will print # out a report on which tests failed and why. If your doctests all pass, # this will print 'All tests passed.' import doctest fails, tests = doctest.testmod() if tests == 0: print("No doctest examples provided.") elif fails == 0: print("All tests passed.") else: print(fails, "tests failed.")