ArjanCodes
11 minutes
Functions and classes organize programs around different concerns: functions are action-focused, taking inputs and returning results so that data flows from one step to the next, while classes in object-oriented programming are state-focused, grouping variables into objects whose methods modify that state. The guiding rule is to use functions when a program is mainly a sequence of transformations and classes when it must model entities that hold state and exist in multiple instances. This belongs to software design and programming paradigms (functional versus object-oriented), and Python's multi-paradigm design allows combining both.