Files
cybr108/lab-02/problem-01.py
T
2026-09-12 20:22:22 -04:00

19 lines
551 B
Python

# 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")
# Instructions: Enter a value to be divided
dividend = 93
# and a value to divide by
divisor = 0
divide(dividend, divisor)