[Instructor] - In this self check exercise,
we'd like you to study once again the try it function
to figure out what's going to be displayed
when this function gets called with the value 10.7
which is a floating point number and the string, Python.
So go ahead and pause the video
and think about that for a moment,
then come back to see the answer.
Okay, let's take a look at this function definition.
So if we pass the float value 10.7 into this function,
here we're going to try to convert that float value
into an integer, which will work
and truncate the floating point part.
So X will become the value ten.
Because this executes successfully,
the except clause would be skipped, the else clause
however will print that the integer representation
of 10.7 is ten and then the finally clause will execute.
So let's stop there for a moment.
We'll define the function here in our first snippet,
and let's execute the call with 10.7
to confirm the two things that will be displayed.
Remember, the finally clause is always going to execute
if the flow of control entered the corresponding try suite.
So that confirms that here as well.
Now going back up above, if we call with the string Python,
of course this try suite's statement
will cause a value error exception.
So the try suite will terminate
and will jump immediately to the except clause.
In this case, it will print out
'Python could not be converted to an integer.'
The else clause will not execute
because the try suite did not complete successfully
but the finally clause will always execute.
So we'll get the except clause's print statement
and the finally clause's print statement
in this case, and just to confirm that,
you can see that is indeed the case.