Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > efe60a74a55b1603654f3f258ba7199d > files > 2889

python3-twisted-19.2.1-1.1.mga7.armv7hl.rpm

# -*- test-case-name: calculus.test.test_base_3 -*-

from __future__ import division


class Calculation(object):
    def _make_ints(self, *args):
        try:
            return [int(arg) for arg in args]
        except ValueError:
            raise TypeError(
                "Couldn't coerce arguments to integers: {}".format(*args))

    def add(self, a, b):
        a, b = self._make_ints(a, b)
        return a + b
    
    def subtract(self, a, b):
        a, b = self._make_ints(a, b)
        return a - b

    def multiply(self, a, b):
        a, b = self._make_ints(a, b)
        return a * b

    def divide(self, a, b):
        a, b = self._make_ints(a, b)
        return a // b