A for loop can iterate over a string in order to use one character at a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A for loop can iterate over a string in order to use one character at a time. Alter the code below to use a for loop and the string "2143" to recreate the same song. The new version should only contain one call to fitMedia() and one += operator. 1 from earsketch import * 2 3 init() 4 setTempo (70) 5 6 7 8 9 10 11 12 start += 1 S = "Y13_PERCUSSION_" start = 1 num= "2" fitMedia(s num, start, start, 5) 13 14 num= "1" 15 fitMedia(snum, start, start, 5) 16 start += 1 17 18 num= "4" 19. fitMedia(snum, start, start, 5) 20 start += 1 21 22 num= "3" 23 fitMedia(snum, start, start, 5) start += 1 24 25 26 finish() PYTHON 10 num= "2" 11 12 13 14 15 16 17 18 19 fitMedia(s + num, start, start, 5) 20 start += 1 21 22 23 24 start += 1 25 26 finish() fitMedia(s+ num, start, start, 5) start += 1 num = "1" fitMedia(s + num, start, start, 5) start + 1 num = num = "3" fitMedia(s+ num, start, start, 5) A for loop can iterate over a string in order to use one character at a time. Alter the code below to use a for loop and the string "2143" to recreate the same song. The new version should only contain one call to fitMedia() and one += operator. 1 from earsketch import * 2 3 init() 4 setTempo (70) 5 6 7 8 9 10 11 12 start += 1 S = "Y13_PERCUSSION_" start = 1 num= "2" fitMedia(s num, start, start, 5) 13 14 num= "1" 15 fitMedia(snum, start, start, 5) 16 start += 1 17 18 num= "4" 19. fitMedia(snum, start, start, 5) 20 start += 1 21 22 num= "3" 23 fitMedia(snum, start, start, 5) start += 1 24 25 26 finish() PYTHON 10 num= "2" 11 12 13 14 15 16 17 18 19 fitMedia(s + num, start, start, 5) 20 start += 1 21 22 23 24 start += 1 25 26 finish() fitMedia(s+ num, start, start, 5) start += 1 num = "1" fitMedia(s + num, start, start, 5) start + 1 num = num = "3" fitMedia(s+ num, start, start, 5)
Expert Answer:
Answer rating: 100% (QA)
Recreating the same song using a for loop and the string 2143 w... 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
-
You run a zoo and you've decided the best attraction to increase the number of visitors are flamingoes! Specifically, Deb the Flamingo! You've designed a flamingo-sized hamster-style ball that Deb...
-
A researcher wanted to find out if there was difference between older movie goers and younger movie goers with respect to their estimates of a successful actors income. The researcher first...
-
Why due diligence, both legal and financial, is important for the song catalog purchase? Why it is important to understand the details of sources of income, how and when it is earned, and how it is...
-
International Paper reported the following items for the current year: Sales = $3,500,000; Cost of Goods Sold = $1,250,000; Depreciation Expense = $170,000; Administrative Expenses = $150,000;...
-
Calculate the total splitting w of the spectral line 3D3 3P2 in a weak magnetic field with induction B = 3.4kG.
-
1. Say that someones body temperature is measured by four different devices andthe resulting four measurements are given below. Which reading has an absoluteerror of 0.05 C? A. 38 C B. 37.8 C C....
-
Use the equation (17.19) suggested by Pai for the turbulent stress and integrate for the velocity profile. How do the results compare with that of Prandtl? = 0.9835 H+ (1-#)['-(1-#)'] (17.19) H+
-
On August 1, 2010, Christy Co. treasurer signed a note promising to pay $121,500 on December 31, 2010. The proceeds of the note were $114,000.00 rev: 05-10-2011 19.value: 15.00 points You did NOT...
-
Jacquelyn's business had a budget of $154,000 in sales and $95,980 in total variable costs. What is the most her fixed costs could be for the businen to break even?
-
Ray Flagg took out a 60-month fixed installment loan of $12,000 to open a new pet store. He paid no money down and began making monthly payments of $232. Ray's business does better than expected and...
-
How does pH relate to the brightness of the light bulb in a fruit battery with a lemon, potato, apple, tomato cucumber, eggplant, and banana?
-
What is the output of the following application? (Choose two.) A. 2 B. 3 C. 5 D. 6 E. 8 1: public class ChooseWisely { 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:} public ChooseWisely () { super(); }...
-
Which is the first line to fail to compile? A. r1 B. r2 C. r3 D. r4 E. r5 F. None of the above class Tool { } private void repair() {} void use() {} } // r1 // r2 class Hammer extends Tool { private...
-
What does the following output? A. block B. constructor C. instance D. The code does not compile. E. None of the above. 1: public class InitOrder public String first public InitOrder () { 2: 3: 4: 5:...
-
What is true of the following method? A. It is a correctly implemented accessor method. B. It is a correctly implemented mutator method. C. It is an incorrectly implemented accessor method. D. It is...
-
How many lines of the following program do not compile? A. Zero B. One C. Two D. Three E. More than three. 1: public enum Color { 2: 3: 4: 5: 6: 7: 8: 9: } RED (1,2) { void toSpectrum () {} }, BLUE...
-
Fee structure is equal to 50% of any investment returns. Any earned fees would be offset against prior losses until those losses had been entirely recouped. Fees are billed quarterly. The JV's...
-
A business had revenues of $280,000 and operating expenses of $315,000. Did the business (a) Incur a net loss (b) Realize net income?
-
Bea Jones (age 32) moved from Texas to Florida in December 2011. She lives at 654 Ocean Way, Gulfport, FL 33707. Bea's Social Security number is 466-78-7359 and she is single. Her earnings and income...
-
On February 2, 2012, Alexandra purchases a personal computer for her home. The computer cost $3,000. Alexandra uses the computer 80 percent of the time in her accounting business, 10 percent of the...
-
Mary paid $2,000 of state income taxes in 2012. The total sales tax she paid during 2012 was $5,500, which included $3,000 for the cost of a new car. How should Mary treat the taxes paid on her 2012...
-
The simplified financial statements of two companies, P and Q, are shown in Figure 7.8. Assuming that interest is charged on the long-term loan at 10 per cent per annum, calculate the following...
-
For which sort of business might the ratio of receivables to sales be the lowest (and therefore the debtors collection period the shortest)? A. A market stall selling vegetables. B. An audit firm. C....
-
What is the return on capital employed? A. 39.0% B. 44.9% C. 48.0% D. 17.8% E. 34.0% Using the following balance sheet and income statement Balance sheet m Property 200 Trade payables Plant and...
Study smarter with the SolutionInn App