Creating a simple Function in python || python code for creating function

← Back to Home

🔹 Functions in Python

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

we can pass data, known as parameters, into a function.

A function can return data as a result.


# In Python a function is defined using the def keyword:

🔸 Example : Creating a Function

def my_function():
  print("Hello function" )



🔸  Calling a Function

To call a function, we use the function name followed by parenthesis

 Example :


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

my_function()    # Here is Function call by its name


Featured Post

Python Math Module Quiz: 20 MCQs with Answers

Python Math Module Interactive Quiz Test your knowledge of Python's math module, mathematical functions, constants, rounding, powe...

Popular Posts