-
Standard Functions
These are the most basic functions in Python. They are defined using the def
keyword, followed by the function name and parentheses ()
. For example:
1 def add(a, b):
2 return a + b
2. Built-in Functions
In Python, the entire application, however, comes with many built-in functions, which are part of the Python standard library. These functions are defined by the Python developers and are available for use in any Python program. Some examples of built-in functions are len()
, max()
, min()
, and str()
.
3. Lambda Functions
These are anonymous functions in Python, which means they do not have a name. They are defined using the lambda
keyword, followed by the function parameters and a colon :
. The function body consists of a single expression that is returned as the result of the function call. For example:
1 # A lambda function that adds two numbers
2 add = lambda a, b: a + b
Meanwhile, the Lambda functions are often used as arguments to other functions when a simple function object is needed for a short period of time.
About Author
Discover more from SURFCLOUD TECHNOLOGY
Subscribe to get the latest posts sent to your email.