nobodydml
nobodydml nobodydml
  • 15-12-2021
  • Computers and Technology
contestada

Write code using the range function to add up to the series 20,30,40, ...90 and print the resulting sum each step along the way

Write code using the range function to add up to the series 203040 90 and print the resulting sum each step along the way class=

Respuesta :

mark454
mark454 mark454
  • 15-12-2021

Answer:

Code:

 

range_sum = 0  

for x in range(20, 100, 10):  

   range_sum += x

    print(range_sum)

Explanation:

Declare variable (we'll use it to keep track of the sum):

range_sum = 0

Start a loop with the range function (x is the current number, 20, 100 are the numbers to start and stop by and 10 is the number to increase by):

for x in range(20, 100, 10):

Add the current number to the sum and print it:

range_sum += x  

print(range_sum)

Answer Link

Otras preguntas

what is 6=1–2n+5?????
what is the number and word form of 100,203
92.96 as a mixed number in simplest form
The __________ is the central part of the play’s story, where the main action takes place and problems arise. climax rising action exposition
Adverbs can modify all of the following except A)Verbs B)Adjectives C)other Adverbs D) Nouns
Which statement is true according to Dalton’s theory? a. Atoms of different elements can join to form larger atoms. b. Atoms can be subdivided into smaller part
speed of sound.. If I am travelling at 1/2 the speed of sound, and there are sounds coming from behind me and in front of me. I understand they will sound at di
what is the value of n? 9×27+2×31-28=n
round 762 to the nearest hundred
which figure appears to have only 1 line of symmetry