Create a Python script which will accept two positive integers where the first
number would be the start of a range and the second number would be the end of a
range. Then the application will determine the sum of all EVEN numbers and sum of all
ODD numbers from the given range.
Sample Output:
Start of a Range: 5
End of a Range: 10
Sum of Even nos. is 24
Sum of Odd nos. is 21
start = int(input("Start of a Range: "))
end = int(input("End of a Range: "))
even, odd = 0, 0
for i in range(start,end+1):
if i%2>0:
odd += i
else:
even += i
print(f"Sum of Even nos. is {even}")
print(f"Sum of Odd nos. is {odd}")
Comments
Leave a comment