Create a function addNumbers(start, end) that adds all the integers between the start and end value (inclusive) and returns the total sum.
Answers
Answer is in the attachment...... hope
Create a function addNumbers(start, end) that adds all the integers between the start and end value (inclusive) and returns the total sum.
Explanation:
# Python program to adds all the integers between the start and end value (inclusive)
# Function definition
def addNumbers(start, end):
sum = 0
i = start
while i<=end:
sum = sum + i
i = i + 1 # increment i on each iteration
return sum
start = int(input())
end = int(input())
# displaying output
print( "Sum of all the integers between",start ,"to",end, "is", addNumbers(start,end))
Output
10
20
Sum of all the integers between 10 to 20 is 165