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

Please help me find the correct answer to 1&2
Wich Indo-European invader influenced civilization in the fertile Crescent
What are some benefits and drawbacks of the internet crashing forever
solve y = 12x + n for n need help please
Write 0.5 in simplest form
As a result of british landowners evicting peasants from their lands in the sixteenth and seventeenth centuries:
Find the measure of each interior angle AND each exterior angles of the following regular polygons. Show your work. a. Pentagon b. 16-gon c. Dodecagon
Find out he area of the circle.
Can anybody help with this, please?
SV is an angle bisector of ∠RST. If m∠RSV = (2x + 6)° and m∠RST = (6x − 28)°, find x.