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

Scientists are sending a rover to the moon. Their plan is to study a rectangular area of the moon by placing a grid over the map as shown. On the grid, 1 unit r
Can someone say happy birthday to me do it for how every many point this question is gonna give yoouuu
What atom requires the greatest amount of ionization energy na or mg
Which expression is equivalent to 18x^2√14x^8 / 6√7x^4, if x ≠ 0?
45 Points! The moon forms a right triangle with the Earth and the Sun during one of its phases, as shown below. A scientist measures the angle x and the distan
I need help asap!!! I will without hesitation give brainliest to whomever gets this
Twice a number x increased by 32 is translated to 2x+32
Write your answer in simple solution (4x^3+2x+6)+(2x^3-x^2+2)
A landowner owned a three-acre plot of land in a remote location. His plot abutted a two-acre wooded property that contained an artesian spring owned by an out-
HELP PLEASE ILL MAKE YOU THE BRAINIEST What is the area of the regular polygon?