Function in Python

pythoncode4you

Python Tutorial



In previous blog we learn basic concepts about python and datatypes of Python and operators in Python and also we learn the loops in python. The link of the python datatypes blog is pythoncode4you and python loops blog link is pythoncoding4you. The link of the python if-else statementispythoncoding4you

Functions in Python

In this blog we learn how to add function in our python code. There are so many functions we directly use in the Python programming. Using of functions we can reduce the code and also we can use it again and again.


First we see that what is meant by Function?

Function is block of code that is used to perform a specific action.The advantages of using functions are:

  • Reducing the code
  • Code Reusability
  • Improving the clarity of code

There are two types of functions in Python programming these are as follows:

  • Built-in functions
  • User-defined functions

1.Built-in Functions

Built-in functions means the functions which are already exist in the python that is functions that are pre-defined in Python.

Examples:
  • print()
  • range()
  • input()
  • len()

Program:

Output:


2.User-defined Functions

User-defined functions are those functions which are defined by user to perform a specific task. These functions are not already exist in python.

Examples:
  • add()
  • multiplication()

Program:

Output:

3 Comments

Previous Post Next Post