Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class Calculator(object):
  2. def power(self, n, p):
  3. if (n < 0) or (p < 0):
  4. raise Exception("n and p should be non-negative")
  5. else:
  6. return n ** p
  7.  
  8.  
  9. myCalculator = Calculator()
  10. time = int(input())
  11. for i in range(time):
  12. n, p = map(int, input().split())
  13. try:
  14. ans = myCalculator.power(n, p)
  15. print(ans)
  16. except Exception as e:
  17. print(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement