Program to illustrate the type exception in python
try:
num1 = int(input("Enter First Number: "))
num2 = int(input("Enter Second Number: "))
result = num1 / num2
print(result)
except ValueError as e:
print("Invalid Input Please Input Integer...")
except ZeroDivisionError as e:
print(e)
Output:
Run 1:
Enter First Number: 432.12
Invalid Input Please Input Integer...
Run 2:
Enter First Number: 43
Enter Second Number: 0
division by zero
Run 3:
Enter First Number: 331 2
Enter Second Number: 4
83.0
Program to illustrate the type exception in python
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer