Python Chapter-4 PPT
Python Chapter-4 PPT
❑ Function Definition
❑ Function Calling
<function_name>()
Arguments
➢ Input values given to function
➢ Arguments are specified by parameters in function definition
Parameters
Arguments
Return Values
➢ Whatever function gives as outcome is defined as return values
➢ Uses ‘return’ keyword
Return Values
Multiple Parameters
➢ Positional Parameter : Arguments values are identified based on their
position
Argument at pos = 0
Argument at pos = 1
Multiple Parameters
You get
tuple of
arguments
Lambda Function
➢ Anonymous functions at runtime
➢ Can take any number of arguments
➢ Can only have one expression
➢ Uses ‘lambda’ keyword to define Arguments
return (3 * fact(2) ) = 6
return (2 * fact(1) ) = 2
1
Modules
➢ Logically organize your python code in module
➢ Module is just a python file
➢ Module can define functions, classes, variables
daily.py weekly.py
Packages
➢ Hierarchical organization of modules
➢ Package is a directory consists of modules and file named as : __init__.py
weatherman
weatherman is a package
consists of daily and weekly
modules
➢ Use ‘weatherman’ package in another python file using ‘from’ and ‘import’ statement
www.paruluniversity.ac.in