Computer Science [Python]

Exceptions are errors, or the unusual and unexpected situations that are not a part of the normal flow of program. Exceptions are convenient in many ways for handling errors and special conditions in a program. Whenever an exception occurs in the program, it should be raised using the raise statement. Once an exception is raised, it is up to the caller function to handle it using try/except statement. The exception name can be string/class/object and argument is the value. The argument is optional and its default value is NONE. The exception raised by raise statement need to be handled using the try…except statement. The try…except is used in incase when the programmer thinks that the code might fail. single try statement can have multiple except statements. The finally statement will allow the execution of a code in any case if the try block raises an exception or executes successfully. Iteration is a repetition of a process in a computer program. An iterator is an object that allows sequential access to an underlying sequential data. An iterable is an object that represents a sequence of one more values. Yield statement allows the function to suspend the processing and send a value, simultaneously retaining the existing state of generator to resume the processing overtime.

To Access the full content, Please Purchase