Function

Functions.

A function is a block of code which only runs when it is called.

In Python programming, Functions is a group of related statements that performs a specific task. You can pass data, known as parameters, into a function. A function can return data as a result.

Functions make our program more organized and help in code re-usability.

Features of Functions

Functions help in code reusability.
Functions provide organization to the code.
Functions provide abstraction.
Functions help in extensibility.

Creating a Function
In Python a function is defined using the def keyword:

Example :
def my_function():
  print("Hello from a function")

Calling a Function
To call a function, use the function name followed by parenthesis:

Example :
def my_function():
  print("Hello from a function")

my_function()

Thank you very much for reading carefully, if you have any other questions, you can share it with us through comments, if this information was important to you, please let us know through comments.

Please do comment and share.
Thank You.

Comments

Popular posts from this blog

What is Data Structure ?

Python Program to Calculate the Area of a Triangle