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

Page No. 2. On the summit i we Rech the Top. Q1] Complete the following web giving the reasons for not knowing kasabai of rice Kasabai​
please solve for brainliest!
instuctiunea for unde s=1*3+2*4+....+n(n+2)
What Is Your Decade-In-Review For The 1990s From News, Sports, Politics, Entertainment, Trends, Movies, TV Shows And Pop Culture Fads From 1990 To 1999?
find the side length and area and pls explain how ​
divide 2x^3-x^2-12 by x+3
2. A skier is skiing downhill. A. Copy the forces in the diamgram, then label the weight, W, of the skier and the reaction, R, of the slope. B. Show the di
components of dispensing​
Mr. Bissell creates a diagram of electric and magnetic fields to teach his students about the concepts. He includes the similarities and differences between the
What is the greatest positive integer ‘m’ which makes m3 100 is divisible by mplus10