Convert this for loop, which traverses by element, into a for loop that traverses by index....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Convert this for loop, which traverses by element, into a for loop that traverses by index. Then convert it into a while loop. n is an integer of your choice and word is a variable assigned to a string. You will have to use string indexing. for ch in word: print(ch" n) Once you have written code for your loops, or as you're developing them, choose three examples to demonstrate that all of the loops are result in the same outcome. You should use three different words and potentially three different values of n, whatever you choose! Convert this for loop, which traverses by element, into a for loop that traverses by index. Then convert it into a while loop. n is an integer of your choice and word is a variable assigned to a string. You will have to use string indexing. for ch in word: print(ch" n) Once you have written code for your loops, or as you're developing them, choose three examples to demonstrate that all of the loops are result in the same outcome. You should use three different words and potentially three different values of n, whatever you choose!
Expert Answer:
Answer rating: 100% (QA)
define word as string and n as integer values word Apple n 3 print... View the full answer
Related Book For
Discrete and Combinatorial Mathematics An Applied Introduction
ISBN: 978-0201726343
5th edition
Authors: Ralph P. Grimaldi
Posted Date:
Students also viewed these programming questions
-
What are the molecular mechanisms underlying the sensing and signaling of oxygen levels in cells and tissues, and how do they regulate processes like erythropoiesis, angiogenesis, and cellular...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Prepare journal entries to record each of the following sales transactions for the sales company. The company uses a perpetual inventory system and the gross method. 1. April 1st Sold for $3,000,...
-
A 120-mm-radius pulley of mass 5 kg is attached to a 30-mm-radius shaft which fits loosely in a fixed bearing. It is observed that motion of the pulley is impending if a 0.5-kg mass is added to block...
-
February 26 The company paid cash to Lyn Addie for eight days' work at $120 per day. March 25 The company sold merchandise with a $2,400 cost for $3,200 on credit to Wildcat Services, invoice dated...
-
What is the use of a context diagram?
-
Refer to the data given in Problem 4.34 and suppose that the expected activity costs are reported as follows (all other data remain the same): Other overhead activities: Activity Cost Purchasing...
-
Manvir had to make payments of $1,125 every 6 months to settle a $22,000 loan that he received at 4.52% compounded semi-annually. a. How long did it take to settle the loan?
-
Summarizes current non-GAAP reporting practices in the industry; TOYOTA VS HONDA Include tables or other appropriate visualizations that reflect information about your companies, including...
-
Complete problem: Cost of Equity-CAPM Xez, Inc. has a beta of 0.8. The yield on a 3-month T-bill is 4%, and the yield on a 10-year T-bond is 6%. The market risk premium is 5.5%, and the return on an...
-
Write four tweets to persuade other college students to take the business communication course. Think of the first message as the headline of an advertisement that makes a bold promise regarding the...
-
Communication Ethics: Distinguishing Ethical Dilemmas and Ethical Lapses [LO-5] Briefly explain why you think each of the following is or is not ethical. a. Keeping quiet about a possible...
-
Which sentence is in the active voice? a. The report will be written by Leslie Cartwright. b. Leslie Cartwright will write the report. 4. Which sentence is in the passive voice? a. The failure to...
-
The following paragraphs contains a variety of errors, potentially involving spelling, grammar, capitalization, punctuation, abbreviation, number style, word division, or vocabulary. Identify them...
-
Interpersonal Communication: Conversational Skills Pair off with another student and initiate a conversation in which one of you will express concerns about the way one of your courses is progressing...
-
A stock with a current price of $32 will either move up to $40.00 or down to $30 over the next period. The risk-free rate of interest is 2.3%. What is the value of a call option with a strike price...
-
For the following exercises, find the area of the triangle. Round to the nearest hundredth. 22 50 36
-
For [w,x,y,:) determine the number string in of length 5 (a) that start with r; (b) with precisely iwo w's; (C) with no w's; (d) with an even number of ws.
-
(a) Explain why it is not possible to draw a loop-free connected undirected graph with eight vertices, where the degrees of the vertices are 1, 1, 1, 2, 3, 4, 5, and 7. (b) Give an example of a...
-
Let G = (V, E) be the undirected connected "ladder graph" shown in Fig. 11.94. (a) Determine |V| and |E|. (b) Prove that P(G, λ) = λ(λ - 1)( λ2 - 3...
-
If a politician running for office does not speak in general terms, does not try to move to the middle of the political spectrum, and does not take polls, is the median voter model therefore wrong?
-
Voters often criticize politicians running for office who do not speak in specific terms (i.e., who do not specify which spending programs will be cut, whose taxes will be raised, etc.). If voters...
-
Why is rent-seeking activity socially wasteful?
Study smarter with the SolutionInn App