Sobes.tech
Junior — Middle

Can you name the main features that distinguish a pure function?

sobes.tech AI

Answer from AI

Main characteristics of a pure function:

  • Determinism: the function always returns the same result given the same inputs.
  • No side effects: the function does not modify external state (e.g., global variables, files, databases).
  • Does not depend on external state: the result depends only on the parameters passed.

Example of a pure function in Python:

def add(a, b):
    return a + b

This function always returns the sum of two numbers and does not modify anything outside itself.

Can you name the main features that distinguish a… - sobes.tech