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?
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
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 ;-)
> 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
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!!
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?
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
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
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 ;-)
I really love your analogies they work so well
Thank you
> 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
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!!