mika's open learning notebook

notes on programming, linux, software, and whatever i'm learning


Python · September 3, 2026

September 3, 2026 — 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 (myFunction and myfunction are different)