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

Which of the following reflect a period of détente in the Cold War? A.Conflicts in Korea and Vietnam B.Publications such as NSC-68 C.Nuclear disarmament talks D
In the late 1800's and early 1900's nationalism * 1.brought instability to Germany 2.prevented World War I 3.inspired people who shared a particular language o
use the dot product to find |v| when v=(2,7)
Maria quiere que yo le blank mi numero de telefono
In a ________, two or more companies at one level join together to follow a new marketing opportunity. franchise multichannel distribution system conventional d
a triangle has 2 sides that equal 7 inches. The other side equals 3 inches. What kind of triangle is it
EXPERTS/ACE/GENIUSES PLZ HELP
How is romeo standing lifelessly?
Which part of cellular respiration would be stopped if arsenic were ingested?
The second bullet struck the Archduke close to the heart. He uttered only one word, “Sofia” —a call to his stricken wife. Then his head fell back and he collaps