Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 "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
Step: 1
The provided image shows a Python code excerpt for a function titled compute which takes two paramet...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started