What are functions in Python?
- A function is a block of code which only run when it is called.
- A function can return data as a result.
- To define a Python function, the
def
keyword is used.
Example:
def my_function():
print("Hello!. I am a function!")
my_function()
#Output:
Hello!. I am a function!