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

What do we call structures that have different mature forms, but develop from the same embryonic tissue? A. vestigial structures B. homologous structures C. mut
Fjjfnd djdndjdnndnddn dndnxndn
life scientist study life and the many processes that occur in living things____-
Find the domain of the function using interval notation. f(x) = 6 x − 9
Each morning you feed your dog 2525 cup of dry dog food. At night, you feed him 1212 cup of dry dog food. You buy a bag of dog food that contains 1818 cups. How
_______is the process of paying off a debt with regular fixed payments.
I need help, to see if i got it right
A farmer builds a fence for his chickens in the shape of a pentagon, as shown. Each of the 5 sides has equal length, but the fence along the highway costs twice
Write an explicit and a recursive formula for the sequence. (5,11,17,23,29)
Pweees help me fast here..... Salma takes 15 mins from her house to reach her school on bicycle. If the bicycle has the speed of 2 m/s, calculate the distance b