Python
Python Functions
Basic notes on defining, naming, and reusing functions in Python.
- Functions are blocks of code that only run when called.
- A function can return data or be reused.
- Functions help avoid code repetition.
def my_function():
print("Hello from a function")
Functions follow the same naming rules as variables in Python:
- names must start with a letter or underscore
- names can contain letters, numbers, and underscores
- function names are case-sensitive (
myFunctionandmyfunctionare different)