Python def Keyword

Example

Create and execute a function:

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

Run Example

Definition and Usage

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

related pages

Please visit our Python ฟังก์ชัน Learn more about functions in the tutorial.