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 was a significant impact of the emancipation proclamation?
what is £300 in a ratio of 3:7
Solve the equation 6x+3y=15for y what does y equal if x=2 if x=5
can 111/500 be simplified
in adults, where are the stem cells that produce new neurons
what is the relationship between height and energy ?
a shampoo advertized in your favorite magazine claims to have a secret ingredient that will make your hair thicker and shinier how could you test the claim?
how do you find the decimal and fraction equivalent of 175%
Compare and contrast basic research, applied research, and technological development.
Who was responsible for the attack pictured in this image? Iraq Iran Al-Qaeda Afghanistan