HR30 Day 17: More Exceptions/Python

개요[ | ]

#Write your code here
class Calculator(object):
    def power(self, n, p):
        if n<0 or p<0:
            raise Exception("n and p should be non-negative")
        return n**p
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)
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}