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 your biggest turn off in a guy or girl? ( Just a question for you guys to answer )
Find the percent using the percent equation. 238 cartons is what percent of 68 ​cartons?
Evaluate the expression when x=-2 and y=2. -9x+y X 5 ?
What is the solution to the following equation? x2 + 5x + 7 = 0 O A. x = 5:3 O B. x= 33.475 O c. x==37x7 O D. x = -52753
Who was the first president in the USA Plz help
Pleaseeee help !!! I need this pleaseeee
A system of two equations is shown below. What will you need to multiply the top equa order to solve this system using the elimination method? 2x +y = 11 5x + 3
Which angles pairs are congruent? Select all that apply. A. <ALF and <KLIB. <BKH and <FLKC. <CIE and <JILD. < DJK and <JILE. <EIJ and
can anyone please help me with this one ?:)
Question 2 of 20 :-th--LLLLSelect the best answer for the question.STEETPIELILENELLHETERHEThenPIESELLERWAT2. This question is based on the following paragraph.