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

Can my 12 year old son take 10mg melatonin. As 5mg as not been working on him.
One major choice an author of fiction makes is to decide the _________________ from which the story is told. A) time of day B) point of view C) first name of th
Help pls, I’m doing a timed exam
The misinformation effect is an example of a mnemonic device. Please select the best answer from the choices provided T F.
how long does it take for meclizine to work for vertigo
X (6x + 51). Х ? 69 2 .
please help i am stuck with this problem please help
Name of the first colony that the British tried to build, it would later be abandoned and known as, “The Lost Colony".
how do spell these nuts??
translate the phrase into an algebraic explanation. the quotient of x and 5​