Question: 13. Rewrite the following code that counts Davids in a text string to be easier to understand def Davids (text): one 1 letters text.split

13. Rewrite the following code that counts

13. Rewrite the following code that counts "David"s in a text string to be easier to understand def Davids (text): one 1 letters text.split () for index in range (len (letters)) : if index == 0: value = 0 if letters [index] == 'David': value + one if index = len (letters) -1: return value As a test print (Davids ("David is a cool David")) would print 2, for the 2 "David". (15 pts) If else What would be output by the following Python code and calls to the function? def compute (number1, number2): if numberl> number2: if number1 < number2 + 10: return numberl else: return number2 elif numberl ! = 10: return 2 else: der Davidsetext) One I letters let. Split() for index in range (len (letters)): return 1 What would print? 14. 15. 16. print (compute (30,10)) print (compute (10,20)) print (compute (30,25)) 17. Write a function status_from_age that takes in an age in years. If the age is less than one, return "baby". If the age is from one up to but not including ten, return "kid". If the age is from ten up to but not including twenty, return "teen". If the age is twenty or above, return "adult". As an example, status_from_age (10) would return "teen".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The provided image shows a Python code excerpt for a function titled compute which takes two paramet... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!