Python def keyword

Example

Create and execute the 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 Learn more about functions in the tutorials.