In [ ]: In [ ]: In [ ]: In [ ]: Q2 - Method II...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In [ ]: In [ ]: In [ ]: In [ ]: Q2 - Method II (1.25 points) .split() is a built-in string method that "returns a list of the words in the string". .count() is a built-in list method that "returns the number of times a specified value occurs in a tuple." You may wish to examine the contextual help for both methods to do this problem. In the cell below, the variable students_fruits has been provided for you. Using only students_fruits and the methods split() and count(), generate the three variables specified at left in the bulleted list below, satisfying the following criteria: • apple_count the number of times 'apple' shows up in students_fruits lychee_count | the number of times 'lychee' shows up in students_fruits • pineapple_count | the number of times 'pineapple' shows up in students_fruits ● Do not hard-code. Use your code to process the list so that we could change the list and you'd still generate the correct answer automatically. That is DON'T write something like: apple_count = 5 Note you will have to execute the cell with the variable provided below before being able to reference it in your answer. 1 hese variables provided for you 2 ou will not be able to edit this cell 3 4 dents fruits = 'apple apple apple banana pear dragonfruit starfruit apple pear pineapple apple grapefruit lime lych 5 6 nt (students fruits) 1 # ignore this cell; it's being used in grading 2 # be sure to put your answer in the cell below this cell 3 1 #your code here 2 raise Not ImplementedError 1 assert apple_count is not None In [ ]: In [ ]: In [ ]: In [ ]: Q2 - Method II (1.25 points) .split() is a built-in string method that "returns a list of the words in the string". .count() is a built-in list method that "returns the number of times a specified value occurs in a tuple." You may wish to examine the contextual help for both methods to do this problem. In the cell below, the variable students_fruits has been provided for you. Using only students_fruits and the methods split() and count(), generate the three variables specified at left in the bulleted list below, satisfying the following criteria: • apple_count the number of times 'apple' shows up in students_fruits lychee_count | the number of times 'lychee' shows up in students_fruits • pineapple_count | the number of times 'pineapple' shows up in students_fruits ● Do not hard-code. Use your code to process the list so that we could change the list and you'd still generate the correct answer automatically. That is DON'T write something like: apple_count = 5 Note you will have to execute the cell with the variable provided below before being able to reference it in your answer. 1 hese variables provided for you 2 ou will not be able to edit this cell 3 4 dents fruits = 'apple apple apple banana pear dragonfruit starfruit apple pear pineapple apple grapefruit lime lych 5 6 nt (students fruits) 1 # ignore this cell; it's being used in grading 2 # be sure to put your answer in the cell below this cell 3 1 #your code here 2 raise Not ImplementedError 1 assert apple_count is not None
Expert Answer:
Answer rating: 100% (QA)
To solve this problem we can follow these steps Split the string studentsfruits in... View the full answer
Related Book For
College Accounting A Practical Approach
ISBN: 9780135222416
14th Canadian Edition
Authors: Jeffrey Slater, Debra Good
Posted Date:
Students also viewed these programming questions
-
Write an alternative definition that is tail-recursive (iterative) and makes use of accumulator variables. [10 marks] Explain why your alternative definition executes more efficiently. [3 marks] 1...
-
PLEASE GIVE CORRECT ANSWERS Prove that the number of comparators in any sorting network is (n log n). [4 marks] (ii) What does Part (d)(i) imply in terms of the depth of any sorting network? [1 mark]...
-
Explain fully the role played by unplanned investment in inventories in determining equilibrium in the Keynesian model. Use the examples of AD > GDP and AD < GDP to illustrate your answer.
-
A satellite is placed in Earth orbit at an altitude of 23,300 mi, which is 1100 miles higher than the altitude of a geosynchronous satellite. (a) Is the period of this satellite greater than or less...
-
For this exercise, we use JTRAIN.RAW to determine the effect of the job training grant on hours of job training per employee. The basic model for the three years is (i) Estimate the equation using...
-
What is bivariate regression?
-
Layla meets with her insurance agent, Trong, to discuss her insurance needs. Layla has an after-tax income of $3,800 per month, her rent is $1,200, and her other expenses total $1,500 per month....
-
Your company is an international property firm that is keen to introduce a new hotel brand in Singapore. As their Marketing Manager, you are tasked to make recommendations whether they should do so....
-
Suppose the general solution to some ODE is y = c cos(3x) C2x6 + C3 arctan (x9) + ex - We would say the solution set is an n-parameter family, for which n?
-
What do vampire teach us about humanity and being human (about mortality and fragility; about love and hate; about religion, beliefs and rituals; about fears of the unknown and the different, etc.)?...
-
1. For the following program segment, give the output produced by the segment: 1 int i = 13; 2 while (i> 0) { int j = 2; while (j
-
3. Write an algorithm to compute the distance s fallen by an object in free fall. The formula is: S=So +Vot+/2a1 where so is the initial position in feet, vo is the initial downward velocity in...
-
1. Solve the given system of equations using Cramer's rule. 3x + 5y = 6 4x - y =7 (b) 2y+z+=-1 -2-y + 3x= -1 -2x+3:+2y=5
-
2. In the following code, suppose that f is an instance of Foo. Answer Question 2. a. b. C. class Foo { d. } static int x; static int s; Which of the following statements is incorrect? f.smethod ();...
-
You are a buyer of mens casual pants. A sales representative for a major supplier has advised you that your next shipments of a particular item you have been selling will be identical to your normal...
-
Find the velocity, acceleration, and speed of a particle with the given position function. r(t) = (t 2 , sin t - t cos t, cos t + t sin t), t > 0
-
Super Sweets of Edmonton, owned and operated by Sophia Blanca, uses a purchases journal (page 15) and a general journal (page 3) to record the following transactions (use separate columns for...
-
Enter the beginning balances in the MyLab Accounting Excel templates or the Workbook working papers. Post the following adjusting entries (be sure to cross reference back to the journal) that came...
-
Freja Nilsson opened Frejas Cosmetic Market on December 1. Freja offers no sales discounts. The following transactions occurred in December: 2023 Dec. 1 Freja Nilsson invested $6,000 in the Cosmetic...
-
In Fig. 122, although a Sending may have multiple assessments, they must all be from different reviewers. The current model does not guarantee it. Write an invariant that deals with this issue....
-
Consider Fig. 13-28, try to present a concentration version of this diagram and present the corresponding (smelling) code. Interface : Controller send proposal(a_proposal_id,a_federal_manager_id) a...
-
Considering Fig. 13-26, a Proposal has an association to Sending that is 1 to *{ordered} stack. Considering that this association is bidirectional, show the mutual-friends implementation of its...
Study smarter with the SolutionInn App