Articles β†’ Python β†’ Functions In Python

Functions In Python






What Is A Function?





Example




# this is the function definition
def HelloWorld():
    print("Hello World")
    return


# this is the function call
HelloWorld()




Picture showing the output of the HelloWorld function in python





Passing Parameter In The Function




# this is the function definition
def HelloWorld(name):
    print("Hello ", name)
    return


# this is the function call
HelloWorld("gyan")




Picture showing the output of a function with input parameters



Returning A Value From The Function




def WelcomeMessage(name):
    name = "Hello" + name
    return name

welcomeMessage = WelcomeMessage("gyan")
print(welcomeMessage)




Picture showing the output of a function with return statement



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, February 28, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250