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

Why did Bill Clinton win the presidency in 1992?
9 is 18% of what number
How to solve y for this problem:16x + 9 = 9y - 2x.I am thinking the answer is y=2x, but I'm not sure
The weight of an object is the product of its mass, m, and the acceleration of gravity, g (where g=9.8 m/s2). If an object’s mass is m=10. kg, what is its weigh
How do you simplify -14/63
Identify the simple subject in the following sentence.George Washington was one of the greatest generals in American history.A.generalsB. wasC.George Washington
One radio station broadcasts a weather forecast every 18 minutes and another broadcastsA commercial every 15 minutes. If both stations broadcast both a weather
2/3 = 1/2q ? Can show me the steps to do this Can anyone do this for me step by step 2/3=-1/2q
When  liquids are exposed to air, they what??
Father Hidalgo's call for independence was taken up by who after Hidalgo's death