Find the sum of numbers in a given range In Python

     

         Find the sum of numbers in a given range In Python

Program:

    startnum = int(input("Enter Start Number" ))
    endnum = int(input("Enter Ending Number"))
    sum = 0
    for i in range(startnum, endnum + 1, 1):
    sum = sum + i
    print(sum)


    OutPut:
    Enter Start Number1
    Enter Ending Number10
    55

    Enter Start Number20
    Enter Ending Number30
    275




    For More Information Visit: http://msktutorials.com/





    No comments:

    Post a Comment