Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 7b973fb3c8298f606d9b435aff551ab6 > files > 2937

python2-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