Answer to Question #303052 in Python for Loki

Question #303052

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

1
Expert's answer
2022-02-27T04:23:21-0500
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}")

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