Calling Functions Via Variable Declaration in "Coffee Chatbot"

In general, when a function is stored as a variable, is that function automatically called? In the first few steps of the “Coffee Chatbot” project, we are asked to define function get_size() and include it in the definition of function coffee_bot():

Inside your coffee_bot() definition, call the get_size() function and store the returned value in a variable called size . Print out size to see the value!

Here, simply storing “get_size()” as variable “size” within the function “coffee_bot” results in “get_size()” being called whenever “coffee_bot()” is called. Is this always the case with functions stored as variables? Does it matter if the variable in question is declared in or out of another function?


Yes, the function is called, and the variable will hold the value it returns, None is returned if the function doesn’t return anything.

1 Like