Answer to Question #303080 in Python for Christine

Question #303080

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:16-0500
Start = int(input("Enter Start of the Range: "))
End   = int(input("Enter End of the Range  : "))


SumEven=0
SumOdd=0
for r in range(Start,End+1):
    if(r%2==0): SumEven=SumEven+r    
    if(r%2==1): SumOdd =SumOdd+r    


print("Sum of Even Numbers: ",SumEven)
print("Sum of Odd  Numbers: ",SumOdd)

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