Calling a Function in Python

PythonServer Side ProgrammingProgramming

Defining a function only gives it a name, specifies the parameters that are to be included in the function and structures the blocks of code.

Once the basic structure of a function is finalized, you can execute it by calling it from another function or directly from the Python prompt. Following is the example to call printme() function −

 Live Demo

# Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
# Now you can call printme function
printme("I'm first call to user defined function!")
printme("Again second call to the same function")


When the above code is executed, it produces the following result −

I'm first call to user defined function!
Again second call to the same function
Published on 29-Jan-2020 15:40:26