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

the sum of seven-tenths of a number and.forty
If f(x) = x2 is vertically stretched by a factor of 17 to g(x), what is the equation of g(x)? O A. 9(x) = 7*? O B. g(x) = O C. g(x) = 177 O D. g(x) = (17x)
A recipe calls 1/5 teaspoon of baking powder. If the recipe is tripled, how much bakingpowder is needed?​
This is a sample question I'd like to ask
help me plzzzzzzzzzzzzz​
what fraction is equivalent to 16.6 repeating
The practice of taming wild animals Question 7 options: domestication agricultural revolution divide and conquer hunt and gather
Please help……………………………………
the length of a rectangle is represented by 2x + 4 and width is 3x + 6 the perimeter is 55 units find the value of x
i need this please someone help !! Put in proper sequence __ creation of man __ fall of man __ redemption through christ __ serpent tempting Eve __ devil ca