• + 4 comments

    Is there any reason for creating instance variable self.n and self.p ? and also inherting object class ?

    I wrote following working code:

    class Calculator:
        def power(self, n, p):
            if n < 0 or p < 0:
                raise ValueError('n and p should be non-negative')
                
            return n ** p