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 were the four things momma always used to talk about to Bud about?
Well................................
Where do American Indians live today? Can someone please tell me
Pls help 15 points Which model best represents 33 1/3%
someone wanna heelpp!!!!!​
$12,000 deposit, simple interest at 8.5% for 5 years.
A father and his son are riding their bicycles for fun outside. The son gets in an accident and the father takes him to the hospital. The son goes to the operat
Which classification best describes the relationship between <2 and <4?
If right I’ll mark brainliest
if P= (-1,-1), find the image of P under the following rotation. 180 degrees counterclockwise about the origin