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