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

Which quotation from chapter 2 of Night by Elie Wiesel best demonstrates the author’s viewpoint about the dehumanization of the passengers?
Which image shows a nonrenewable resource? sun fire can plant
The volume is 4,500 pie what’s the radius
Carbohydrates carbohydrates contain glucose
In addition, what is the inverse of this number? Enter the number that belongs in the green box. 317
If a one-on-one conversation fails to convince the person, ... A. then it's best to let them be. B. then try to get a couple of friends to support you. C. then
which expression is equivalent to (4^5/4 4^1/4/4^1/2) ^1/2
Which energy source allowed factories to move away from rivers? OA. Water OB. Oil O C. Coal O D. Steam
help me please helppppp ​
CORRECT ANSWER GETS BRAINLIST