In this article, we will show you, How to write a Python Program to find Sum of Even and Odd Numbers from 1 to N using For Loop with example.

**TIP: **I suggest you to refer Sum of Even, and Sum of Odd numbers articles to understand the logic behind sum of Even and odd numbers.

## Python Program to find Sum of Even and Odd Numbers from 1 to N using For Loop

This Python program allows the user to enter the maximum limit value. Next, it is going to print even and odd numbers from 1 to that user entered limit value.

In this example, For Loop will make sure that the number is between 1 and maximum limit value. Next, we used If Else to check the even number.

**TIP: **Please refer Even or Odd Program to understand the logic

# Python Program to find Sum of Even and Odd Numbers from 1 to N maximum = int(input(" Please Enter the Maximum Value : ")) even_total = 0 odd_total = 0 for number in range(1, maximum + 1): if(number % 2 == 0): even_total = even_total + number else: odd_total = odd_total + number print("The Sum of Even Numbers from 1 to {0} = {1}".format(number, even_total)) print("The Sum of Odd Numbers from 1 to {0} = {1}".format(number, odd_total))

**OUTPUT**

## Python Program to find Sum of Even and Odd Numbers from 1 to N without If Statement

This is same as above. However, this program allows user to enter Minimum and maximum value. Next, it will print even and odd numbers between Minimum and maximum value.

# Python Program to find Sum of Even and Odd Numbers from 1 to N minimum = int(input(" Please Enter the Minimum Value : ")) maximum = int(input(" Please Enter the Maximum Value : ")) even_total = 0 odd_total = 0 for number in range(minimum, maximum + 1): if(number % 2 == 0): even_total = even_total + number else: odd_total = odd_total + number print("The Sum of Even Numbers from 1 to {0} = {1}".format(number, even_total)) print("The Sum of Odd Numbers from 1 to {0} = {1}".format(number, odd_total))

**OUTPUT**