brii5292 brii5292
  • 10-06-2020
  • Computers and Technology
contestada

Write code using the range function to add up the series 99, 98, 97,...
1 and print the resulting sum.
Expected Output
4950

Respuesta :

MrRoyal
MrRoyal MrRoyal
  • 15-06-2020

Answer:

This program is written in python;

Comments are used for explanatory purpose;

Take note of indentations (See picure attachment)

Program starts here

#Initialize Sum to 0

sum = 0

#Iterate from 99 to 1 using range function

#The iterating variable i starts from 99 and ends at 1 with a difference of -1

for i in range(99, 1, -1):

sum+=i

#Display Result

print("Expected Output: ",sum)

#End of Program

Ver imagen MrRoyal
Answer Link

Otras preguntas

What are some problems facing mammals today?
Could plant roots do photosynthesis? Give reasons for your answer.
what is 2.4166666666666 as a fraction
Where do most people in Venezuela live?
what does this equal? 6(x+1)+5=13-2+6x
Identify the type of sentence. After the supplies are delivered, we will decorate the room. simple sentence compound sentence complex sentence
Jacksonian democracy is associated with which of the following? Rejection of a national bank Rejection of states' rights Rejection of strict interpretation of t
Which statement explains why the Middle region was known as the "breadbasket"?The borders of the Middle region were shaped like a bread basket.In the Middle reg
A cone has a diameter of 18 inches. and a height of 14 inches. What is the volume of the cone?
"two cars got an oil change at the same auto shop.the shop charge customers for each quart of oil plus a flat fee for labor the oil change for one car required