As a definition, I learnt that,
non-pure functions have some input (their arguments) and return some output (the result of applying them) [...] and in addition [...] can also generate side effects, which make some change to the state of interpreter or computer.
(Paraphrased from Building Abstractions with Functions (PDF).)
For example: the print(2)
function returns nothing (None
) in addition as a side effect print function (not Python interpreter) itself prints the value.
In the above definition, I did not understand the meaning of 'changing the state of interpreter or computer'. What does that mean?