Answer to Question #330745 in Python for sura karthik

Question #330745

Write a program to find the sum of odd numbers in first N natural numbers.


1
Expert's answer
2022-04-19T08:07:06-0400
def is_odd(x):
    return x%2!=0
N=int(input('N= '))
s=0
for i in range(1,N+1):
    if is_odd(i):
        s+=i
print('sum of odd numbers=', s)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS