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

someone can help me for my speaking test,I will mark brainlest.​
In one area, the lowest angle of elevation of the sun in winter is 24degrees Find the distance x that a plant needing full sun can be placed from a fence that i
What kind of shape will you see if you cut a cross section parallel to the base of a cylinder
The Is the treatment you manipulate in an experiment?
helppp, graph of function!! ​
Which keywords and phrases in this author's purpose indicate that the author should use a descriptive essay structure? Karen is writing about her experiences in
Please help? Describe three stretching exercises that can be performed by adults at an average fitness level and then discuss at least two health benefits of st
In ΔDEF, the measure of ∠F=90°, DF = 24, FE = 7, and ED = 25. What ratio represents the sine of ∠E?
The book of Philemon belongs to the section of the New Testament known as
A job calls for installing 270 lighting fixtures. If 81 fixtures have been installed so far, what percent of the job still has to be done?