As like C python also allow to device a large program into the basic block is known as function.
In function curly bracket contain the set of programming statements {}
A function can be called more than one time to provide reusability to the user.
Table of Contents
Two types of function in python
- User defined function
- Built in function
We know that user defined function are those function declared by user to perform some specific task.
Python built in function are those function that are predefined in python
Advantage of function in python
- With the help of function, we can avoid same logic or code again and again
- We can call python function multiple time in aprogram and anywhere in python
Syntax of function in python
def my_function(parameters):
function block
return expression.
Example:
def sach():
print("PS")
sach()
Here we create sach function and pass the parameters then finally call sach function we got output is PS.
Two types of function in C
- Library function
- User_defined function
Library function are the function which are declared in the c header file sach as a scanf(), printf(), puts() etc.
user defined function which are make by C programmers
Syntax of C function
Sr. No. | C Function | Syntax |
1 | function declaration | return_type function_name (argument list) |
2 | Function call | function_name (argument list) |
3 | Function defination | return_type function name (argument list) {function body;} |
Summary:
In this article we saw difference between function for C and python so about this article you have any query then free to ask me.