Computer Science, asked by akashpunkstr3791, 9 months ago

Create a function addNumbers(start, end) that adds all the integers between the start and end value (inclusive) and returns the total sum.

Answers

Answered by Abhis506
0

Answer is in the attachment...... hope

Attachments:
Answered by ridhimakh1219
2

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

Similar questions