jonestheprob1150 jonestheprob1150
  • 23-05-2022
  • Computers and Technology
contestada

Write a pseudo code to print sum of all even numbers from 1 to 100

Respuesta :

notleoprobably
notleoprobably notleoprobably
  • 03-06-2022

(python) Answer:

sum = 0

for i in range 1 to 101:

 if i modulo 2 == 0:

   sum += i

print(sum)

Explanation:

first we declare the sum variable

then go through all numbers 1 through 100 (range 1 to 101 because python range does not include the last number - if we did 1 to 100 it would look at 1 to 99)

if the number is even (divide by 2, check if there's a remainder, if not it's even and we will add the number to the sum

finally print the sum

Answer Link

Otras preguntas

HEKP ASAP. BRAINLIEST TO FIRST CORRECT ANSWER. Answers you can choose from: (A) 5.0 (B) 6.5 (C) 7.0 (D) 8.5
Why does Walt not join in conversation between his wife and Skiff Miller
If point A is located at (-3,-1) and there are 10 points between A and B, what could be the possible coordinates for point B?
How did the magna carta chabge the relationship between the monarch and the people
Theodore Dreiser was a fine writer of the romantic school Naturalist school Gothic school
HELP ASAP! WILL MARK YOU BRAINLIEST AND GIVE YOU 20 POINTS!
ASASP HELP!!!!!!!PLATO!!!!! HELP!!!!!Robert Bork wrote an article opposing a Supreme Court decision about ruling on married couples because he said there was no
in which medium would sound travel the fastest
I need some help on this
Which of the statements in the last activity expresses the main idea about communication? Letters express our feelings and ideas. Many of these types of comm