Articles → Python → Functions in python

Functions in python






What is function?





Example




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

# this is the function call
HelloWorld()





Click to Enlarge




Passing parameter in function




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

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





Click to Enlarge


Returning value from function




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

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





Click to Enlarge


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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250