00:01
Oh, okay, so in this question, we want to have the division of two integer numbers and release error message if the input is not a valid input.
00:14
So if we don't have two integers as an input and have another error message if we divide by zero.
00:22
So we're going to first start by defining a function.
00:24
We're going to call it simply division.
00:26
And it's going to take two input called user num and divnum.
00:39
And so those are the two input.
00:42
And just to make sure our function reads correctly, we're going to print user num and print div.
00:52
And here i'm going to call my function.
00:57
I'm going to call division, which one and two and i see what that does so it does indeed print one and two so that's a good start now we want to make sure first is we want to catch zero division error so what we're going to do we're going to need a try accept block so we're going to try we're going to try to write the result is equal to user num divided divided by divv none and if that doesn't work we want a zero division error so if this is built in in python you don't need to do anything so you're going to try to do this and there's a division by zero it should catch it immediately and we want and i'll put an exception message using it okay so we're just going to try just going to print invalid cannot divide by zero and here just for fun we're going to print so let's say we try to divide 1 and 2 and we run our program gives 0 .5.
02:57
So that's okay.
02:58
Let's say we try to divide by 10 and 2 gives us 5.
03:05
That's also good.
03:07
Now we also want to make sure that our numbers are integer and input and output an error message if they are not.
03:20
So we're going to have another exception called value error, which is also built into python.
03:29
You don't need to do anything to have this exception.
03:35
And we're going to print.
03:37
What i mean is included in python.
03:39
This value error, you don't need to import any package...