Question: Complete a function named sum_range with the following header: def sum_range(start_num, end_num): signature: int, int -> int precondition: end_num >= start_num Returns the sum

Complete a function named sum_range with the following header:

def sum_range(start_num, end_num): """

signature: int, int -> int precondition: end_num >= start_num Returns the sum of all numbers between start_num and end_num """

That is, the function is named sum_range; it takes two integer parameters, start_num and end_num, such that end_num is not less than start_num; and it returns an integer equal to the sum of all numbers between start_num and end_num, inclusive.

For example:

print(sum_range(5, 5)) print(sum_range(-4, 4)) print(sum_range(0, 10)) print(sum_range(1, 11))

# 5

# 0

# 55

# 66

Test your function before submitting it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!