8 Comments
User's avatar
Abbaan Nassar's avatar

I wonder, is the python function the coffee machine, or is the python language the coffee machine, or is my operating system the coffee machine? Or is my computer the coffee machine?

Stephen Gruppetta's avatar

In the analogy, the coffee machine represents the function. You provide it with stuff (coffee, water, electricity) and these are the arguments you use when you call the function, and it gives you hot, liquid coffee—the function's return value.

Of course, analogies are just that, of course, and they always fail if you push to far, but this is a good way of visualising what a function does

Srikrishna Sajjarao's avatar

Stephen!!!!

Wow, I am trying to understand the function concept from the last 5 days. You made me understand it in 10 mins.

Thankyou so much. Love you

Stephen Gruppetta's avatar

I'm glad you found it useful! Hopefully you'll find some other interesting articles on The Stack, too, although some may cover slightly more advanced topics…

…but you may enjoy The Python Coding Book, too ;-)

Slack System's avatar

I really love your analogies they work so well

Slack System's avatar

> Unless you're prepared to tilt your head in an awkward position, open your mouth, and position it directly in the coffee stream's path—I don't recommend this—the coffee will go to waste.

If you actually *do* do this though, then you are the variable

Stephen Gruppetta's avatar

Yes and no. With analogies it always depends on interpretation.

If you do this, you’re not “storing” the coffee for later use but using it directly. Later in the article, I link this to calling the function directly within another function call’s parentheses…

..but yes, you could be the variable too, under a different interpretation!!