delanynaidu7111 delanynaidu7111
  • 10-02-2020
  • Computers and Technology
contestada

Below, we’ve provided a for loop that sums all the elements of list1. Write code that accomplishes the same task, but instead uses a while loop. Assign the accumulator variable to the name accum.

Respuesta :

sandlee09
sandlee09 sandlee09
  • 12-02-2020

Answer:

Explanation:

The code that would best accomplish this task using a while loop would be the following:

list1 = [8, 3, 4, 5, 6, 7, 9]

accum = 0

n = 0

while n < 7:

        accum += list1[n]

        n += 1

This code will continue throughout the list1 array and add every value to the accum variable.

Answer Link

Otras preguntas

What is the greatest common divisor of 54, 36, and 24?
Over time, Americans’ expectations of government have generally ________? A. Increased B. Decreased C. Been related to national defense D. Been related to f
This one day menu for a malnourished child provide significantly more nutrition than a well-nourished child one need. how many calories per day are in this menu
Can someone please help me on 20 and 21
What is the 4 lines of communication
What is the size of each interior angle in a regular polygon woth 20 sides
When does a story’s initiating event occur? A. between the rising action and the climax B. between the rising and falling actions C. between the climax and the
The graph shows the relationship between the total cost and the number of gift cards that Raj bought for raffle prizes.
what is the value of x in the equation x+4=11
Can someone help? ?!?!?!????!?!