The document defines key Python concepts such as functions, modules, and packages, along with exceptions and their types. It outlines the advantages of user-defined functions, syntax for defining functions and importing modules, and explains namespaces and predefined exceptions. Additionally, it describes recursive functions with an example.
The document defines key Python concepts such as functions, modules, and packages, along with exceptions and their types. It outlines the advantages of user-defined functions, syntax for defining functions and importing modules, and explains namespaces and predefined exceptions. Additionally, it describes recursive functions with an example.
Function: A block of code that performs a specific task when called. Example: def greet(): print('Hello')
Module: A Python file (.py) containing definitions and statements.
Example: math module
Package: A collection of modules organized in directories with __init__.py file.
2) Define Exception. An exception is an error that occurs during execution and disrupts the normal flow of the program. Example: ZeroDivisionError, FileNotFoundError.
3) Enlist advantages of user defined function.
- Code reusability - Easy to debug and maintain - Improves code clarity - Allows modular programming
4) Write syntax of user defined function.
def function_name(parameters): # function body return value