Python User Defined Functions

Python User Defined Functions

Functions are generally defined for the piece of code which is repeatedly used across many places in a project. Functions are also defined to separate complex processing from the main code. Broadly there are two type of functions in Python:


Named Functions: Name functions can be either parameterized(with parameter) or non-parameterized(with no parameter). Named functions must be defined using 'def' keyword.



Lambda(Anonymous) Functions: Anonymous functions are functions which are defined without name. Named functions must be defined using 'def' keyword while Anonymous function must be defined with 'lambda' keyword. Lambda functions are very useful and powerful one liner functions.