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

I will award brainliest
What is the relationship between the national response framework and nims.
Did you know that EddieVR is great at horror games
At the outbreak of the Civil War in 1861, pro-Union sentiment was strong in western Virginia, eastern Tennessee, and western North Carolina primarily because A
5 . Scott had $12.58. He purchased two apples for $1.13 each and one bottle of juice for $1.76. • There was no sales tax. How much money did Scott have after hi
I keep failing this test plzz help me
Maia and Chris were discussing a type of climate characterized by very low precipitation, localized extreme variations in temperature from day to night with org
What does it mean when your fingers shrivel up in water?
How does audio add information to a presentation? It allows the author to see the person's facial expressions and the camera angle. It allows the reader to see
Akin has some money in a box if 3/8 of the money is #4.80 how much money does she have in a box