Kenny got tired of the classroom and wanted to see more of the outdoors, so he took a job as a farmhand. Kenny, being the capable young man he is, quickly moved up the ranks of the farmhand hierarchy and was tasked with managing a team of new farmhands to harvest the strawberry fields.

“How do I impart my knowledge of harvesting strawberries to these apprentice pickers?” thinks Kenny to himself. Well, whenever Kenny has a task that needs to be done many times over, like harvesting a strawberry, he thinks back to his computer science days and realizes he needs to write a function.

A function is a specific set of repeatable instructions that takes an input, like a strawberry plant, and produces an output, like freshly picked strawberries. If this sounds like the definition of an algorithm, you’re right! An algorithm is conceptual, and a function can put an algorithm into practice.

Kenny finds it helpful to consider functions as he writes instructions on how to harvest strawberries for all of the new pickers. “I need to have explicit, step by step instructions or my pickers will not consistently produce the correct output,” thinks Kenny. By thinking of these instructions as a function he is giving to the harvesters, Kenny ensures that harvesting strawberries is a repeatable, dependable task.


Check out Kenny’s instructions for picking strawberries. By providing these instructions to each farmhand he is able to make sure the process is repeated the same each time without having to manually pick the strawberries himself.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?