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

How do you say "Some brown spiders"?
which Enlightment thinker wrote that people in society are bound to one another by an implicit ' social contract,,
what is 140/216 in simplest forms
which of the following did not trigger Haiti's fight for independence
are there forests in Hungary
PLEASE HELP IS THE OLD YELLER !!!!!!!!!!!! When does Mrs. Coates first demonstrate that she recognizes Travis is taking on his father's role? A. when Travis go
the bases of a softball field are 60 feet apart. How far apart is home plate from second base?
Which best describes a likely result for the circulatory system if the heart is weakened? A. Oxygenated blood would not be pumped to the body's cells via the v
are there forests in Hungary
Simplify. 26 + (–3) ∙ (–8) A. –184 B. –2 C. 2 D. 50