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

Calculate the pKa of lactic acid (CH3CH(OH)COOH) given the following information. 3.005 grams of potassium lactate are added to 100. mL of a 0.500 M lactic acid
To try to bring the U.S. out of its Depression, Herbert Hoover:
If TU=8 and TV = 13
Complete each of the following sentences by using the drop-down menus. sound into Audio digitization converts sound. Digital audio is stored in The process of a
How did the tenth amendment reduce federal overreach into the affairs of state governments?
Please help I cannot find this question
Find y. Give your answer in the simplest form.
please help, what are the answers
what are the functions of plasma membrane??btw hii​
Umberto plants a garden with an area of 16 square feet. What is the area of the garden in square inches