feat: completed problem-01

This commit is contained in:
baphim
2026-09-12 20:22:22 -04:00
parent 42b8628b73
commit f3263d7f94
+10 -3
View File
@@ -1,12 +1,19 @@
# Write a Python program to handle a ZeroDivisionError exception when dividing a number by zero
# Problem 1: Write a Python program to handle a ZeroDivisionError exception when dividing a number by zero
def divide(x, y):
try:
# try to divide the provided values and store in variable: answer
answer = x / y
# print result of division
print(answer)
except ZeroDivisionError:
# handle ZeroDivisionError and prompt user for legal value
print("Enter a non-zero value")
divide(6, 2)
# Instructions: Enter a value to be divided
dividend = 93
# and a value to divide by
divisor = 0
divide(dividend, divisor)