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

President #5 a. James Carter b. James Madison c. James K. Polk d. James Monroe
how many square corners does a pentagon have
Write an addition problem that has 9/10 as the sum
The molecules CH4 and CH3Cl both have tetrahedral shapes. Why is CH4 nonpolar whereas CH3Cl is polar?
finger like extensions of the amoebas cytoplasm are called?
a circular swimming pool is 21 feet in diameter. what is the circumference of the swimming pool
This freedom allows newspapers and television broadcasts to criticize the government. What freedom is this, Petition, Press or Assemble?
what is the type of material that doesn't allow heat to be conducted easily
Which identifies all the integer solutions of the equation |x| = 12? A. 0 only B. 12 and –12 C. –12 only D. 12 only
Which is greater 7/10 or 3/5