-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path8th.py
More file actions
23 lines (17 loc) · 598 Bytes
/
8th.py
File metadata and controls
23 lines (17 loc) · 598 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
try:
# ask user to input two numbers
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
# divide the first number by the second number
result = num1 / num2
# print the result
print("The result is:", result)
# handle exceptions that may occur
except ValueError:
print("Invalid input. Please enter a valid number.")
except ZeroDivisionError:
print("Cannot divide by zero.")
except Exception as e:
print("An error occurred:", e)
finally:
print("Program completed.")