Computer Science, asked by vstthakur0947, 1 month ago

Given a list of integers, L, Write a program to calculate and display the sum of all the odd numbers in the list.​


Thanked: https://brainly.in/question/33596830?utm_source=android&utm_medium=share&utm_campaign=question

Answers

Answered by allysia
5

Program:

\\\tt sum=0\\\tt For\ i\ in\ L:\\\tt {\qquad if i\%2!=0: }  \\\tt {\qquad {\qquad sum+=i }} \\\tt print (sum)

Explanation:

  • For loop will get the values from list in i.
  • If statement checks if the number is odd and adds it in variable sum.
  • Finally we print the sum.

Answered by thugsuting
1

Answer:

i = 1

sum=0

n=int(input("enter the upper limit"))

while i <= n :

sum=sum+i

i = i + 2

print("sum =",sum)

Similar questions