Def Keyword

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


Syntax of def


def fn_Name :



  • def is keyword to create function.
  • fn_Name is name of the function.
  • Statements are lines of code to be execute inside 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 parameter, it show output as hi!! Python.