Mind map
Python : Dealing with Errors
Map content
Python : Dealing with Errors
Here is some error types
- TypeError : Raised when an unsupported operand type for 2 different DataType
- NameError : Raised when a variable in not found in the local or global scope
- IndexError : Raised when the index of a sequence is out of range.
- OverflowError : Raised when the result of an arithmetic operation is too large to be represented.
- ZeroDivisionError : Raised when 0 is defined as a divisor
Error Handling
- 1__We can transform a code with Errors to a clean code that daesn't cause any Errors
- 2__For that we should use the Try and Except keywords,
- 3__In the "try" we defind the code, and in the "except" we define what the program should do if the code caused the Error definded in the Except block
- Look at this explaining Example
- 1__We can transform a code with Errors to a clean code that daesn't cause any Errors
User-Defined Error's
- 1__In Python there is a way to creat our own Errors, that means that we tell the program that an action caused by a block of code is considered as an Error
- 2__For that we should create a class whit the Error's name and the word "Exception" ......Class Error'sName(Exception): After that we write a message using the triple quotition marks..... like that: """the printing message""""
- 3__We didn't finished yet. we should use the if statement .in this statement we're going to write : raise Error'sName. to raise the Error definded. Then we use the try and except block.
- 4__Look at this Explaining Example
- 4__Look at this Explaining Example
Use of Else and Finally blocks
- Use of else: The else block is used to execute a code if there is no Error detected in the try block
- Use of Finally : The finally block is used to execute a code whatever if a Error is catching or not,
- Look at this explaining Example
Images and files in the map
Information
- Description
- Mind Map on Python : Dealing with Errors, created by Briache Issam on 20/08/2021.
- Created by
- Briache Issam
- Views
- 0
- Rating