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 most important in a representative democracy? A- suffrage B- majority rule C- bill of rights D-legislature
20-13-8=15 simplifying expressions
Will binoculars work properly if their prisms (assume n = 1.50) are immersed in water (nwater= 1.33)? assume that binoculars work properly if the light incident
Use triangle abc to find the value of tan A please help I posted the picture with the problem so lost please help
QUICK ALGEBRA 2 HELP PLEASE. NEEDED ASAP! 3 Q'S!1) What expression belongs in the box? (look at 1st pic for Q and 3/4 options.)D).-4x-242).(picture 2)3).(some o
Can you figure out the formula
I really need to know the answer of this fast plss
What are the coordinates of Z please help need help ASAP
HELPPPPPPPPPPPPPPPPPPPPPP
What kinda of file has a name that ends with .gif???