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


No comments:

Post a Comment

Featured Post

Extra Challenge: Using References Between Documents

  🎯 💡 Extra Challenge: Using References Between Documents Here's an  Extra Challenge  designed to build on the original MongoDB mode...

Popular Posts