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 is the value of In e^4 a 0 b 1 c 2 d 4
Simplify 3xy(5x +3 - 7y)
is success based on the level of intelligence? Explain your answer.
How much force will be needed to lift the bag now? How far will the rope have to be pulled?
find the value of x in the diagram
I need help, so this one question: 1/4 (4+x)=4/3 Is stopping me from being great
What is the volume of this object?
the perimeter of this figure is 70 feet. how long are the unkown sides? 5 ft6 ft10 ft12 ft​
Select all that apply Which of the following budgets are directly based on information from the sales budget? Multiple select question. Direct materials budget
Martin uses 5/8 of a gallon of paint to cover 4/5 of wall. What is the unit rate at which Martin paints in walls per gallon