Challenge: Handle `DivideByZero` Exception
Can we handle the `DivideByZero` exception using `try` and `catch`/`except`?
We'll cover the following
Problem Statement
Divide an integer
by 0
and handle the Divide by zero
exception by using try
and catch/except
in Powershell and Python.
num1= 5
num2= 0
result= num1/num2
Expected Output
An error message Error: Division by zero is not allowed!
when we divide a number by zero.
Coding exercise
This problem is designed to check your understanding, so you are encouraged to solve it on your own. If you get completely stuck, refer to the next lesson which will explain the solution in detail.
Python
Get hands-on with 1400+ tech skills courses.