Lab 3: Strings, Iteration and Recursion
Learning Outcomes
Learning Outcomes
- Gain experience manipulating strings.
- Gain experience solving a problem using iteration.
- Gain experience solving a problem using recursion.
- Implement three different solutions that solve the same problem.
- Download lab3.py
- Rewrite the body of the count_built_in function to calculate and return the number of vowels in the parameter sentence using the built-in count method. For example, if the sentence is I like Jazz music., the function should return 6.
- Rewrite the body of the count_iterative function to count the number of vowels in sentence using a loop. (Do not use the built-in count method.)
- Rewrite the body of the count_recursive function to count the number of vowels in sentence using recursion. (Do not use the built-in count method.)
- 3 points - The count_built_in function is implemented correctly.
- 3 points - The count_iterative function is implemented correctly.
- 4 points - The base case (2 points) and two general cases (1 point each) of the count_recursive function are implemented correctly.
- Consider the following letters to be vowels: a, e, i, o, u, A, E, I, O, and U.