Function / def (Python)
A function is a reusable, named block of code defined with the def keyword. You call it by name to run its code, optionally passing in values called arguments.
Python
Functions help you avoid repeating code and keep programs organized. They can accept parameters and send a result back to the caller with return.
Syntax
def name(parameters):
# body
return valueExamples
Python
def greet(name):
return "Hi, " + name
print(greet("Lee"))Output:
Hi, Lee