Write a Python Program to find Sum of Even and Odd Numbers from 1 to N using For Loop with an example.

**TIP: **I suggest you refer Sum of Even and Sum of Odd numbers articles to understand the logic behind the 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, the For Loop makes 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 Python 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 Calculate Sum of Even and Odd Numbers from 1 to N without If Statement

This Python sum of even and odd numbers program is the same as the above. However, this program allows users to enter Minimum and maximum value. Next, it prints 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**