1.Introduction
A function is a set of specified code in which we given some input and the machine do some computation and gives us the output. Function helps in writing the same code again and again and we can get numerous out once a function is defined. The data is passed in parameters.
Syntax
Function is defined with the keyword ’def’ Followed by a variable name and ended with a colon’:’.
Calling of a function
In above example we called a function by its variable name and assigned a value to a.
In above example we added to value entered by user as many times the user want and we did not have to write the same code again and again because of function.
Types of functions
There are two types of functions:
1.Built-in functions
2.User defined functions
Common examples of built-in functions
1.print( ) function.
2.type( ) function.
3.input( ) function, etc.
User defined function
Functions which are defined by ourselves to perform some specified task are called user defined functions. They make code easy to understand by the user.
Top comments (1)
Good work