Python def Keyword

Example

Create and execute a function:

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

Run Instance

Definition and Usage

The 'def' keyword is used to create (or define) functions.

related pages

Please visit our Python Functions Learn more about functions in the tutorials.