Skip to content

Commit 6e2e753

Browse files
Exception Handling using try and except block,Also with try and mutiple except block.
0 parents  commit 6e2e753

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ExceptionHandling.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#Exception Handling using try and except
2+
3+
try:
4+
print(10/0)
5+
except ZeroDivisionError:
6+
print("Denominator should not be Zero")
7+
8+
#Exception Handling using try with multiple except block
9+
#Here if exception raised in try block then it search for matching except block from top to down manner
10+
try:
11+
x=int(input("Enter value of x:"))
12+
y=int(input("Enter value of y:"))
13+
print("The Division is:",x/y)
14+
except ArithmeticError:
15+
print("ArithmeticError:The Denominator value should not be zero")
16+
except ValueError:
17+
print("ValueError: The value must be integral value")
18+
except ZeroDivisionError:
19+
print("ZeroDivisionError: The Denominator value should not be zero")

0 commit comments

Comments
 (0)