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 advantage does a business letter have over an e-mail?
round 222702 to the nearest ten thousand
What are the Factors of -18
Gary mails 3 to the power of 10 flyers to clients in one week. How many flyers does Gary mail
a warehouse that has three shelves that can hold 8 12 or 16 skateboards. each shell has sections holding the same number of skateboards. what is the greatest
Which war did Modernism follow?
explain why is it important to line up decimals numbers by their place value when you add or subtract them
with regard to age and social class who were the first settlers
What is 6 divided by 6n equals 14
Describe your favorite meal and write a persuasive argument to convince someone to try that meal. please help me