Python Def Keyword

def is one of the Python Keyword. def is used to create the Python user define function. When we have to create a new function we will use the def keyword.


Syntax of def


def fn_Name :



  • def is the keyword to create function.
  • fn_Name is the name of the function.
  • Statements are lines of code to be executed inside the function.


Example of def


#Python def keyword

def greetings(name) :
print ("hi!!",name )




hi!! Python



Here greetings is parameterized user-defined function created by using def. when we called greeting function with “Python” as a parameter, it shows output as hi!! Python.