• + 1 comment

    python3

    import math

    class Calculator: def init(self): pass

    def power(self,num1,num2):
        if num1 >= 0 and num2 >= 0 :
            return num1**num2
        elif num1 >= 0 and num2 <= 0:
            return "n and p should be non-negative"  
        elif num1 <= 0 and num2 >= 0:
            return "n and p should be non-negative"      
        else:
            return "n and p should be non-negative"  
    

    myCalculator=Calculator() T=int(input()) for i in range(T): n,p = map(int, input().split()) try: ans=myCalculator.power(n,p) print(ans) except Exception as e: print(e)