write a program to find sum of even numbers and odd numbers upto n numbers IN PYTHON.
Answers
Answered by
1
Answer:
input(n)
sumodd =0
sumeven =0
for i in range(1,n+1):
if(i%2 != 0):
sumodd = sumodd+1
else:
sumeven = sumeven+1
print(sumodd)
print(" ")
print(sumeven)
Explanation:
We calculate this by using a for loop modulus operation with 2.
Similar questions
Chemistry,
5 months ago
Psychology,
5 months ago
India Languages,
5 months ago
Math,
11 months ago
English,
11 months ago
Chemistry,
1 year ago
English,
1 year ago