Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeinab15 committed Dec 29, 2024
1 parent 6a3fd36 commit 9db3cc7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 16 additions & 3 deletions solutions/sum_range.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
def sum_range(start, end):
"""Calculates the sum of all integers from start to end, inclusive."""
"""
Calculate the sum of all integers from start to end (inclusive).
Args:
start (int): The starting integer.
end (int): The ending integer.
Returns:
int: The sum of all integers from start to end.
Raises:
TypeError: If start or end is not an integer.
"""
assert isinstance(start, int), "start must be an integer"
assert isinstance(end, int), "end must be an integer"
# Ensure start is less than or equal to end
assert isinstance (start, int), "start must be an integer"
assert isinstance (end, int), "end must be an integer"
if start > end:
start, end = end, start
# Calculate the sum of the range
total = 0
for number in range(start, end + 1):
total += number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import unittest
from solutions.sum_range import sum_range

""" Unit tests for the sum_range function. """


class TestSumRange(unittest.TestCase):
"""Unit tests for the Sum_range function."""
"""Tests for the sum_range function."""

def test_positive_range(self):
"""Test with a normal positive range."""
Expand Down

0 comments on commit 9db3cc7

Please sign in to comment.