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 many megagrams are there in 7.020 * 10^-10 nanograms
is a nissan altima 2003 a 6 cylinder car?
It was difficult to fulfill its duties under the articles of confederation because?
3-2x>-5 what is the answer
Which statement was one of the reasons for the successful invasion of northern India by Muslim rulers in the late 1100s? 1)Hindu princes followed the principle
Why did the captains of three ships rebel against Magellan?
Please help!!! What is energy???
Steven was having a normal day when suddenly he felt an overwhelming expansion of his mood. he now feels euphoric, cheerful, optimistic, has boundless energy, a
Most of today's college student population will be eligible to receive full social security retirement benefits when they reach the age of
what was one effect of the hartford convention