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

On a certain day, the temperature changed at a rate of -2O per hour. How long did it take for the change in temperature to be -14O?
a truck can be rented from company A for $160 a day plus $0.80 per mile. Company B charges $80 a day plus $0.90 per mile to rent the same truck . Find the numbe
15-3yi=1/2x+2i X= Y=
What is the difference between an atom and a compound? LI
Find the slope of the line and sketch the graph. 3x + 4y = 25 (dont worry abt sketching)
The histogram shows the scores of students on their most recent history test. How many students scored 80% or better on the test? A. 8 students B. 10 students C
What did the copernican revolution demonstrate
what causes a warm air mass to move over a cold air mass instead of mixing with it
I NEED HELP FAST!! can someone please answer these questions for me!
math T_T. 100 points​