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

Talia uses 10 strawberries and 4 oranges to make 8 servings of fruit salad. Drag oranges and strawberries into the box to show how many Talia needs to make 12 s
A certain number has exactly 8 factors including 1 and itself. 2 of its factors are 21 and 35 what is the number?
Ken saves $140 per month. If this is 2.5% of his monthly income, how much does he earn per month ?
If 1 kilograms of bark can produce about 0.015 kilogram of paclitaxel, how much bark is needed to make 120 kilograms of paclitaxel?
what would this equal and showing work x+36=4x
The state of __________ proved the greatest challenge to VEP workers due to the criminal violence faced there.
All of the following were French settlers to New France except for a. business people b. priests c. fur trappers
How is estimation helpful when adding and subtracting decimals
20,000 is 1/10 of_______
What sacred writings describe the early history of the Hebrews?