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 are the domain and range of this graph?
3a +4b =2. 4a -4b =12 elimination
oye gogainah603 hello ​
I need an answer asap!!
Examine the table, which represents a linear function. Input (x) Output (y) 8 −40 11 −49 14 −58 17 −67 What is the rate of change of the function? Ente
is a pair of scissorrs a lever and wedge?
8. How did children address their parents in colonial times?
63=216. Using exponents, write three more expressions whose value is 216.
HELP! MATH, I NEED TO TURN THIS IN RN! I WILL BE GIVING THE FASTEST (CORRECT) ANSWER! TYSM IF U DO! PICTURE BELOW!
Please look at attachment! Help me = brainliest.