Tamannagaur20 Tamannagaur20
  • 01-11-2021
  • Computers and Technology
contestada

Can someone help me write a code in python to find the sum of all the odd numbers from 1-301.
In which python makes a list of all the odd numbers and uses a loop

Respuesta :

arinaaznaureni
arinaaznaureni arinaaznaureni
  • 01-11-2021

arr = []  #an empty array

for i in range(302):  

   arr.append(i) if i%2 != 0 else None #add a new element, if its odd, else - nothing

print(sum(arr)) #printing the sum of elements

Answer Link

Otras preguntas

How can you use 4s fact to find 7x8? Give the product in your explanation.
• List the six external parts of a computer system and identify which are output and which are input devices.
The North believed the Federal government needed to provide less control over its citizens. a. True b. False
Select the sentence with a clause used as a predicate noun. The boy who arrived here Tuesday was running late. We left the diner late because we saw some old fr
The "Great Three" West African empires were Ghana, Mali, and .
what are two intergers that are also whole numbers
write the number that is .10 more for 5.7
The transport of specific particles through a membrane by channel proteins is known as facilitated diffusion.
Which were results of the construction of the transcontinental railroad? Choose all answers that are correct. a. The railroad opened up the Great Plains and th
Which BEST describes the theme of “The Negro Speaks of Rivers” by Langston Hughes? A. the strength of nature B. the utility of waterways C. the heritage of bla