Lab 3: Strings, Iteration and Recursion Lab 3: Strings, Iteration and Recursion Logistics Due: Thursday, January 31st no later than 11:59 p.m. Partner Info
Lab 3: Strings, Iteration and Recursion Lab 3: Strings, Iteration and Recursion
Logistics
Due: Thursday, January 31st no later than 11:59 p.m.
Partner Information: Complete this assignment individually.
Submission Instructions: Upload your solution, renamed to YourFirstName-YourLastName-Lab3.py to the BrightSpace Lab 3 Dropbox.
Deadline Reminder: Once this deadline passes, BrightSpace will no longer accept your Python submission and you will no longer be able to earn credit. Thus, if you are not able to fully complete the assignment, submit whatever you have before the deadline so that partial credit can be earned.
Learning Outcomes
Gain experience manipulating strings.
Gain experience solving a problem using iteration.
Gain experience solving a problem using recursion.
Assignment
Download lab3.py
Rewrite the body of the count_built_in function to calculate and return the number of z’s in the parameter sentence using the built-in count method. For example, if the sentence is Jazz music played during the movie Zootopia, the function should return 3.
Rewrite the body of the count_iterative function to count the number of z’s 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 z’s in sentence using recursion. (Do not use the built-in count method.)
Grading – 10 points
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.