Skip to content

What is a function?

Python Logo

We need your feedback. Click here!

  • The work can be defined as follows:

"A function is a structured, reusable block of code used to perform a single, associated action."

  • You can have both user-defined and built-in functions.
  • User-defined functions, as defined by the category name, are functions and use them as often as you like.

How do you define your function?

def function_name( parameter(s) ):
    # enter your code here.
    return your_value
  • function_name: give your function a nme
  • parameters: Your function can have parameters
  • return: Your function can return a value to the main program that called it. You don't always have to return the value of your work.

You must write the code needed to achieve the function's objective in the function definition block.

Our company offers online and in-person Python training. (Register)[https://www.stuntbusiness.ca/register] now and join the community.

Official documents: Functions