콘텐츠로 이동

two_numbers

TwoNumbers dataclass

Example class that adds two numbers.

Source code in src/my_project/two_numbers.py
@dataclass
class TwoNumbers:
    """Example class that adds two numbers."""

    num_1: int
    num_2: int

    def add(self) -> int:
        """
        Add two numbers together.

        Examples:
            >>> TwoNumbers(1, 2).add()
            3

            >>> TwoNumbers(1, -1).add()
            0

        Returns:
            The sum of the two numbers.

        Note:
            This function only supports integers.

        Todo: You can put title here.
            * Add support for floats.
            * Add support for strings.
        """
        assert isinstance(self.num_1, int)
        assert isinstance(self.num_2, int)
        return self.num_1 + self.num_2

add()

Add two numbers together.

Examples:

>>> TwoNumbers(1, 2).add()
3
>>> TwoNumbers(1, -1).add()
0

Returns:

Type Description
int

The sum of the two numbers.

Note

This function only supports integers.

You can put title here.
  • Add support for floats.
  • Add support for strings.
Source code in src/my_project/two_numbers.py
def add(self) -> int:
    """
    Add two numbers together.

    Examples:
        >>> TwoNumbers(1, 2).add()
        3

        >>> TwoNumbers(1, -1).add()
        0

    Returns:
        The sum of the two numbers.

    Note:
        This function only supports integers.

    Todo: You can put title here.
        * Add support for floats.
        * Add support for strings.
    """
    assert isinstance(self.num_1, int)
    assert isinstance(self.num_2, int)
    return self.num_1 + self.num_2