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

Rounding 51,732 to the nearest 10th
Iron oxide reacts with aluminum to give aluminum oxide and iron. what kind of chemical reaction is this?
What is the square root of 80
The minimum and maximum temperature for a day in Cupcake Town can be modeled by the equation below: 3|x − 8| + 15 = 18 What are the minimum and maximum temperat
Greatest to least 56.2,56.32,56.321
Paul drives his delivery van 675 miles in 3 days. At this rate, how far will he drive in 15 days?
What are the four ways that most traits are inherited?
What is Eight by the power of negative two
simplify 5(x - 2) 3x 8x - 2 8x - 10 -7x
round 28.37 to the nearest whole number