A Function is a block of code that performs a specific task or set of task. Functions are defined by specifying a name for the function l. A set of input parameters and a set of instructions that should be executed when the function is called.
When a function is called it runs the instructions and may return a value or perform some other actions.
For Example:
1: A function could be use to add 2 numbers together
add_number(x,y)
returnx+y
2: calculate a average of list of numbers
3: perform complex data analysis task.
4: calculate factorial of given number:
factorial(n)
If n ==0
return 1
else
return n*factorial(n-1)
factorial ()
Parameters and Dr return value:- That allows û to take input and produce output.
Parameters :- parameters are values that are passed into a function to modify its behaviour or allow it to perform specific action. They are specified in the function definition
0 Comments