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 tv station began playing music videos in the early 1980s? tnt vh3 musicana mtv
places with mild climates typically have ______ summers and ________ winters. hot; cold hot; cool warm; cool warm; cold
Urgent help please can have any of these
What is the appropriate tone for a cover letter? a. friendly b. authoritative c. scholarly d. professional
Raven wants to buy some movies and music albums with the $185 she has saved up. All the movies she wants are $19and all of the albums she wants are $9. How many
what is the advantage of timing for a full minute to find your pulse?
Cataract and lens replacement uses ____ different approaches
slaves were what europeans wanted most from africa before the 1800s. true or false
38 is 0.02% of what number
five-gram samples of copper and iron are at room temperature. both samples receive equal amounts of energy due to heat flow. the specific heat capacity of coppe