13. Rewrite the following code that counts Davids in a text string to be easier to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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". 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".
Expert Answer:
Answer rating: 100% (QA)
The provided image shows a Python code excerpt for a function titled compute which takes two paramet... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
I'm getting these errors on the following code that wasanswered. I also included the instructions from theassignment at the very bottom. Any help would be muchappreciated. ERRORS: Car.java:18: error:...
-
Find the values of the parameter p > 0 for which the following series converge. k=1 k ^ ( + In k + 1/ P
-
Briefly compare the severity of recessions before and after 1950. What explanations have economists offered for the period of relative macroeconomic stability from 1950 to 2007?
-
Tammy and Barry formed Pheasant Corporation several years ago in a transaction that qualified under 351. Both shareholders serve as officers and on the board of directors of Pheasant. In the current...
-
Perform a thorough influential analysis of the air pollution and mortality data given in Table B.15. Perform any appropriate transformations. Discuss your results. City Mort Precip Educ Nonwhite Nox...
-
On January 14, the end of the first bi-weekly pay period of the year, Rockin Companys payroll register showed that its employees earned $14,000 of sales salaries. Withholdings from the employees...
-
Can you give me a format for creating a loan product for a small business including its credit and collection policy? Kindly explain to me how to do these parts?
-
1. Case Exhibit 2 presents monthly data of units produced and sold, and actual costs incurred, for 24 months. B Create a scatterplot of costs and units. b. From your scatterplot, estimate the...
-
Gloin- who is 39 years old - is employed to the Nasty and Crabbit Bank (NCB), an entity duly licensed under the Banking Act, as the manager for Personal Banking Services. Gloin took out two loans as...
-
Design a PowerPoint presentation for the capital budgeting committee that includes all of the following: Create a brief 1-2 slide description of the proposed programs. Develop a comparison between...
-
uppose the price of a non-dividend paying stock is $50. There exist European call and put options on the stock with one year to maturity and the strike price $50. The call is worth $4.5 and the put...
-
3) What are the tax consequences if gifted his life insurance policy on 12/31/23: John would like to know the tax consequences and filing requirements if he gifts his life insurance equally to his...
-
Assets Current Assets: Cash and cash equivalents Accounts Receivable, net Inventory Total Current Assets Property & Equipment at cost Less Accumulated depreciation Net Property & Equipment Total...
-
After reading the Snowden & Boone (2007) article highlighting contexts in which leaders make contextually appropriate decisions, create a post to share how this framework might be useful in your...
-
You are the managing partner of your own accounting firm. You have a new client the Village of Flowerville. You note the Village is using only one fund the General Fund to account for all the City's...
-
The polar coordinates of a point are given. Find the rectangular coordinates of the point. (-1, - /3)
-
Kent Pham, CPA, is a 45-year-old single taxpayer living at 169 Trendie Street, La Jolla, CA 92037. His Social Security number is 865-68-9635. In 2012, Kent's W-2 as the controller of a local...
-
Ken (age 31) and Amy (age 28) Booth have brought you the following information regarding their income, expenses, and withholding for the year. They are unsure which of these items must be used to...
-
Janie graduates from high school in 2012 and enrolls in college in the fall. Her parents pay $4,000 for her tuition and fees. a. Assuming Janie's parents have AGI of $170,000, what is the American...
-
Use Minitab to obtain the results of Tukey's test for the shear bond strength data from Example 1 in Section 13.1. Approach The steps for obtaining the results of Tukey's test using Minitab, Excel,...
-
Another scientist examines how the presence of a nonnative bird species, the starling, affects other species of birds. Is this a population-level study, a community-level study, or an ecosystem-level...
-
What is the function of the placenta?
Study smarter with the SolutionInn App