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

How many judges are there on State Supreme Courts? 2-4 16-20 5-9 10-15
what is the main purpose of Admission Point Score
Policy is discussed by the realm, or broad subject matter around which policy centers. Think about economic policy, social policy, and foreign policy. Which of
Chase is a 22-year-old college student. according to recommendations of the acceptable macronutrient distribution range (amdr, fat should comprise _____% of his
Select the sub-genres of drama. a.romance b.epic c.musical d.history
Why is violence more likely to occur in a store on Black Friday?
All of the following were effects of the Pinckney Treaty EXCEPT A. it ensured that Great Britain would abandon its military posts on the northern frontier.
Alissa is analyzing an exponential growth function that has been reflected across the y-axis. She states that the domain of the reflected function will change b
Two major sources of energy for normal muscle metabolism?
Describe three stages in the life cycle of a volcano