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

Help I need somebody help
Hellppppp meeeeee plzzzzzz
Gabriel wants to paint the model. How much paint will he need? The area of the square base is in.2. The area of each triangular face is in.2. Gabriel will need
There were conceivably an infinite number of courses he could take during his final semester, but since he worked 8-5, Jake needed to take night classes. He als
Simplify: −(−3)2(5)2(7)3 152 A) -343 B) -127 C) -75 D) 126
what is the advantage of defining a target user
What are the coordinates of the image of vertex are after A reflection across the X axis
factor the GCF from this polynomial 40x-10
What’s the political affairs
The expression CaCo3 - CaO + CO2 is an example of a