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 is the name of upcomming new element?​
Who are the baby boomers?
In this activity, you will record a few sentences in Spanish describing some rules that you have to follow at your school. You can use any audio using any audio
The exponential function, f(x)=2^x, under goes two transformations to g(x)=1/3•2^x-7. How does the graph change select all that apply
When a 83.0 kg. person climbs into an 1600 kg. car, the car's springs compress vertically 1.6 cm. What will be the frequency of vibration when the car hits a bu
The most powerful trade associations represent large industries such as what?
What is the opposite of -8? :D
Determine which equation has the same solutions as the given equation 2x^2 - 12x - 50 = 0 A. (x-3)^2 = 16 B. (x - 6)^2 = 19 C. (x - 6)^2 = 31 D. (x - 3)^2 = 34
A hypothesis that is not supported by the data that has been collected and analyzed is
How many multiples of terms in 6 between 50 and 100