Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSCI 7 Lab Assignment 4 15 Points, Due 4/10/2018 please use python 3.7 Loops All programming languages have a loop capability. Looping is the program

CSCI 7 Lab Assignment 4

15 Points, Due 4/10/2018 please use python 3.7

Loops

All programming languages have a loop capability. Looping is the program logics ability to repeat one or more lines of code either:

A set number of times, a for loop (i.e. 10, 100, 500, 763 or more times)

An unknown number of times (i.e. loop terminates if a tested condition becomes true or as long as the tested condition remains false), a while loop, a do until loop, a do while loop.

This Lab exercise demonstrates the use of the For Loop, a standard loop in all programming languages. C++ standard For Loop format looks like:

for n in range (1, 100):

Loop line 1 code;

Loop line 2 code;

Loop line 3 code;

Loop line N code;

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.The default increment is 1 (a third parameter would be an increment or decrement)

The loop will start at n1 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.Enter a starting loop numeric integer value (we will dispense with GIGO code)

2.Enter a stopping loop numeric integer value

3.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)

4. 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

1 of 2 - Enter Starting Loop Value: 1

2 of 2 - Enter Ending Loop Value: 6

1 + 2 + 3 + 4 + 5 + 6 = 21

Loop ran 6 Times

Run this Again (Y or N):

Notice that the values appear on the same line and there is an = equal sign after the last term . please use python 3.7

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_2

Step: 3

blur-text-image_3

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

Explain all drawbacks of the application procedure.

Answered: 1 week ago

Question

Determine Leading or Lagging Power Factor in Python.

Answered: 1 week ago

Question

16.7 Describe the three steps in the collective bargaining process.

Answered: 1 week ago