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

what kinds of organisms perform photosynthesis
The code of Hammurabi consisted of
Why did most people within the byzantine and persian empires accept islam so easily?
2048 est une puissance de 2. Laquelle?
What times 3 equals 25
what is 2.84 divided by 2
Water molecules are polar, with Select one: a. the oxygen side being slightly positive and the hydrogen side being slightly negative. b. the oxygen and hydrogen
Writting about my friends in french
A bullet is fired horizontally from a height of 78.4 m and hits the ground 2400 m away. With what velocity does the bullet leave the gun?
what would be 40/256 be reduced to