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 with this homework
An object has a mass of 50kg. The gravitational field strength on Earth is 10.0N/ kg. The gravitational field strength on a distant planet is 4.0N/ kg. What is
Which equation represents fertilization? haploid diploid = diploid diploid haploid = haploid haploid haploid = diploid diploid diploid = diploid.
Giving away points! =D
Please please help I’m begging
Tất cả hàng hóa khi qua các kho đều lần lược qua 4 khâu nào: a. Nhập, lưu trữ, chọn lọc, giao hàng b. Nhập, lưu trữ, chọn lọc, xuất kho c. Nhập, lưu trữ, chọn l
Can someone help with this ? Will mark brainlest
Martin has 167.70 to spend on party favors for his birthday m. If he plans on making 26 party bags, how much money can he spend on each?
What transformation maps rectangle QRST to rectangle Q’R’S’T’?
After DNA is duplicated, what is it called? What does it look like?