Functional programming is a style (or “paradigm” if you’re pretentious) where we compose functions instead of mutating state in source . By contrast, imperative programming updates state along the way:
car = create_car()
car.add_gas(10)
print(car.get_gas())
# 10Functional programming composes functions that return new values:
car = create_car()
car_with_gas = add_gas(car, 10)
gas = get_gas(car_with_gas)
print(gas)
# 10Each function’s output becomes the next function’s input. The original car isn’t changed, because add_gas just returns a new copy.