Sum of Even Numbers using For Loop in Python


Source Code

print("Sum of Even Number using for loop ")

start = int(input("Enter the starting value : "))
end   = int(input("Enter the ending value : "))

result=0

for x in range(start,end):
    if(x % 2 == 0):
        result=result+x
        
 
print("Sum of even number is ",result)
To download raw file Click Here

Output

Sum of Even Number using for loop
Enter the starting value : 1
Enter the ending value : 15
Sum of even number is  56