CSCI 127 Hunter College Strings Iteration and Recursion Lab Report Logistics Due: Thursday, May 28th no later than 5pm. Submission instructions: upload you
CSCI 127 Hunter College Strings Iteration and Recursion Lab Report Logistics
Due: Thursday, May 28th no later than 5pm.
Submission instructions: upload your solution, entitled FirstName-LastName-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 and rename it according to the instructions above.
Rewrite the body of the length_built_in function to calculate and return the length of the paramter sentence using the built-in len function (see the documentation here). For example, if the sentence is “Montana State”, the function should return 13.
Rewrite the body of the length_iterative function to compute the length of sentenceusing a loop. (Do not use the built-in length function.)
Rewrite the body of the length_recursive function to compute the length of sentenceusing recursion. (Do not use the built-in length function.)
Grading – 10 points
3 points – the length_built_in function is implemented correctly.
3 points – the length_iterative function is implemented correctly.
4 points – the base case (2 points) and 2 general cases (1 point each) of the recursive function are implemented correctly.
Grading turnaround
All labs graded with scores recorded in BrightSpace no later than lab time (2pm) the following day.
# ————————————–
# CSCI 127, Lab 3 |
# May 28, 2020 |
# ————————————–
# Calculate the length of a string |
# using three techniques. |
# ————————————–
def length_built_in(sentence):
pass
def length_iterative(sentence):
pass
def length_recursive(sentence):
pass
# ————————————–
def main():
answer = “yes”
while (answer == “yes”) or (answer == “y”):
sentence = input(“Please enter a sentence: “)
sentence = sentence.lower()
print()
print(“Calculating length of the sentence using …”)
print(“—————————————“)
print(“Built-in function =”, length_built_in(sentence))
print(“Iteration =”, length_iterative(sentence))
print(“Recursion =”, length_recursive(sentence))
print()
answer = input(“Would you like to continue: “).lower()
print()
# ————————————–
main()
We've got everything to become your favourite writing service
Money back guarantee
Your money is safe. Even if we fail to satisfy your expectations, you can always request a refund and get your money back.
Confidentiality
We don’t share your private information with anyone. What happens on our website stays on our website.
Our service is legit
We provide you with a sample paper on the topic you need, and this kind of academic assistance is perfectly legitimate.
Get a plagiarism-free paper
We check every paper with our plagiarism-detection software, so you get a unique paper written for your particular purposes.
We can help with urgent tasks
Need a paper tomorrow? We can write it even while you’re sleeping. Place an order now and get your paper in 8 hours.
Pay a fair price
Our prices depend on urgency. If you want a cheap essay, place your order in advance. Our prices start from $11 per page.