Python Program to print Sum of First 10 Natural Numbers

Python Program to print Sum of First 10 Natural Numbers


 sum=0

for i in range(1,11,1):

    sum=sum+i

print("The sum of first 10 natural numbers is:",sum)


Output:

The sum of first 10 natural numbers is: 55


Sum of Even Numbers

sum=0

for number in range(11):

    if number%2==0:

        sum=sum+number

print("The sum of even numbers is:",sum)



Output:

The sum of even numbers is: 30


टिप्पणी पोस्ट करा

0 टिप्पण्या