Editor settings

General settings

Save settings

Learn to program with Python

Find the total from a range #

Write a function that takes a range given as a list of two numbers and calculates the sum of all the numbers within that range, including the start and the end of the range.

Example #

calculate_range_sum([1, 5]) returns the number 15. The range [1, 5] includes the numbers 1, 2, 3, 4, and 5. The sum of these numbers is 15.

Tests #

  • calculate_range_sum([1, 5]) should return 15
  • calculate_range_sum([10, 0]) should return 55
  • calculate_range_sum([-5, -1]) should return -15
  • calculate_range_sum([0, -10]) should return -55
  • calculate_range_sum([105, 100]) should return 615
Output will be displayed here