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

You buy a game for $40$40, and the sales tax is $2$2. what percent of the game price are you paying in sales tax?
Which trait would be inheritable? A) taste B) eye color C) personality D) the ability to ride a bike
Select all that apply Help Salt dissolved in water is a solution, therefore _____. A.salt and water are chemically combined B.salt is not chemically bonded to
What is the product of 5/8 and 3/4?
What the answers to the question
which sentence contains a word tjat shoukd he capitalized
In a race, there are 14 runners. Trophies for the race are awarded to the runners finishing in first through fourth place. In how many ways can first through f
What is one advantage a primary source has over a secondary source
Which of the following authors was an American romantic poet? a. Walt Whitman b. Phillis Wheatley c. Jonathan Edwards d. Philip Freneau
a globe is an example of a physical model true or false