Hello Wizards, welcome to the new tutorial on advance python. In the previous tutorial, we discussed some concepts in core python, Now help me to dive into the advance python.
Let me start with the Functions…
In simple function is piece of code that can be re-usable. There are two types of functions.
1)Built-in Functions :
Functions that are built in python like print(),file(),len(),all(),any(). There are total 67 built-in functions in python.
Functions that are created by the user, are called user-defined functions. These are defined according to the client (or) Business requirement.
Let me create a simple function:
1] Firstly, for creating a function we have to use “def” followed by the “Function name” and parenthesis ().
2] The code block within the function should be ended by the colon(:).
By the name itself, it describes that it returns a value from a function, return statement without any expression argument returns “none”.
Forms of function arguments:
1] Required arguments (or) Positional arguments:
Arguments that are passed by us, should match the function parameter from the left to right.
NOTE: Here we have pass all the arguments, otherwise it gives missing argument error.
2] Keyword arguments:
These are some type of assigning values type arguments, specifying a keyword argument in the form of argument name = value.
3] Default arguments:
These type of arguments are written in the format of “argument = Value”, so we got an advantage so that we can declare (0r) not declare the value.