Python Functions are a block of statements that does a specific task. The idea is to put some commonly or repeatedly done task together and make a function so that instead of writing the same code again and again for different inputs, we can do the function calls to reuse code contained in it over and over again.

use_of_function_in_javascript_12.webp

Defining a Function

We can define a function in Python, using the def keyword. A function might take input in the form of parameters.

The syntax to declare a function is:

Python Functions
Syntax of Python Function Declaration

Here, we define a function using def that prints a welcome message when called.