➽ Program:-

num = int(input("Enter a Number: "))

even = 0

odd = 0

 

for num in range(1, num + 1):

    if(num % 2 == 0):

        even += num

    else:

        odd += num

 

print("Sum of all Even Numbers = {0}".format(even))

print("Sum of all Odd Numbers = {0}".format(odd))

➽ Output:-

Enter a Number: 50
Sum of all Even Numbers = 650
Sum of all Odd Numbers = 625