13 Python Functions

Functions are set of instructions or group of code to perfrom specified tasks. We have learned about all basic concepts of variables, keywords, datatypes & loops. Whatever logic we are going to build using those basic concepts, can be put inside the function. We can call the function multiple times whenever it is required. Function implementation reduces the code repetition and makes programming more optimized.

Function Defination: A function can be defined with def keyword with function name.

  • A function will perfrom all the tasks defined inside it.

  • It can also return a value or data to the variable outside the function.

  • It is always good practice to have separate functions for separate tasks.

Note: You can not use keyword name as your function name.

Function Types:

There are basically two types of functions present in python.

  1. Built-in Functions

  2. Custom Functions

Lets see one by one.