Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how do I do this using python? The loop code needs: 1. A loop counter variable (n in the above example) to keep track of

image text in transcribed

how do I do this using python?

The loop code needs: 1. A "loop counter variable" (n in the above example) to keep track of how many iterations this loop has run 2. A starting value (i.e. 1 in the above example) 3. A stopping value (i.e. 100 in the above example) 4. Th e default increment is 1 (a third parameter would be an increment or decrement) The loop will start at nl and increment by 1 until the counter runs to n2 - 1. The loop will then stop at that point. We can substitute variables for the start and stop numeric constant values such as: for n in range (n1, n2 ): Lines of Loop code; This Lab Assignment will allow the user to 1. 3. 4. Enter a starting loop numeric integer value (we will dispense with GIGO code) Enter a stopping loop numeric integer value Run a For Loop from 1 to N times keeping a running count of the loop iteration values (i.e. 1 +2+3+4+5+6 21) Keep a running total of the number of loop counters Display the number of iterations and the total. You might also wish to display the iteration count as the loop progresses: 1 of 2 - Enter Starting Loop Value: 6 2 of 2 - Enter Ending Loop Value: 11 6+7+8+9+10+11= 51 Loop ran 6 Times Run this Again (Y or N): y

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Science Project Ideas In Health Care Volume 1

Authors: Zemelak Goraga

1st Edition

B0CPX2RWPF, 979-8223791072

More Books

Students also viewed these Databases questions

Question

Solve for x: 2(3x 1)2(x + 5) = 12

Answered: 1 week ago

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago