Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7076914

Browse files
More Exceptions
1 parent 337de67 commit 7076914

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎Day 17: More Exceptions.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#Write your code here
2+
class Calculator:
3+
def power(self,n,p):
4+
try:
5+
if n<0 or p<0:
6+
raise Exception
7+
else:
8+
return n**p
9+
except Exception:
10+
return "n and p should be non-negative"
11+
myCalculator=Calculator()
12+
T=int(input())
13+
for i in range(T):
14+
n,p = map(int, input().split())
15+
try:
16+
ans=myCalculator.power(n,p)
17+
print(ans)
18+
except Exception as e:
19+
print(e)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /