W4 M4 Function Error Handling
W4 M4 Function Error Handling
Functions
Error Handling
Prashant K. Sharma
Diptesh Kanojia
e-Yantra Team
ERTS Lab, IIT Bombay
IIT Bombay
October 24, 2020
1 Functions
What is Function ?
Creating Functions
Definition vs. Calling
Testing and Documenting
2 Error Handling
Errors
Syntax Error
Index Errors
Variable Name Errors
Error Handling
What is Function ?
Creating Functions
Syntax Error
Syntax Error
Index Error
Index Error: If the error is due to accessing of a list or string which does
not exist, then that error is called index error
Index Error
Index Error: If the error is due to accessing of a list or string which does
not exist, then that error is called index error
Index Error
primes = [ 2, 3 , 5, 7 ]
print( primes[4] )
Try Except
When an error occurs also called exceptions, the python code stops
executing, we can handle such scenarios using try statements.
Try Except
When an error occurs also called exceptions, the python code stops
executing, we can handle such scenarios using try statements.
References
• Python Errors
• Google Python Style Guide
• PEP 8 Style Guide
Thank You!
Author: Prashant K. Sharma
Contributor: Diptesh Kanojia
Post your queries at: [email protected]/