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 was the result when US troops fought Field Marshall Rommel’s Afrika Korps in the Battle of Kasserine Pass? US forces held out until reinforcements arrived
What is the author's main purpose for including quotations from Ehrenreich's book?
log7(49)=2 in exponential form
Which of the following statements is false? a. abraham lincoln was a unionist. b. sam houston was a unionist. c. abraham lincoln was forced out of office. d. sa
Which fraction below represents a repeating decimal?
Whoever gets it right can have brainliest, but answer ASAP!
How do you quarter pi
please helpthere are ten mistakes I only found 6​
What characteristics do the early Roman calendar and the Islamic calendar share?
What rumors were making everyone "uneasy" in the refugee camp? (a)The camp is running out of food. (b)The water is not clean and will cause illness. (c)Rebel so