After defining a function with the keyword def
, it can be called using the function name.
def printLine():
print("Sample output");
printLine()
Sample output
This code defines a function named printLine
that outputs a string “Sample output” to the console.
The def
keyword is used to define a function, followed by the function name, printLine
, and a set of parentheses ()
. The code inside the function is indented and is the body of the function.
After defining the function, the function is called by its name printLine
followed by a set of parentheses ()
. When the function is called, the code inside the function is executed, and “Sample output” is printed to the console.