I think it really depends on the language and on the function.
While the c and c++ compilers can inline a lot of functions, this is not the case for Python or Java.
While I do not know the specific details for java (except that every method is virtual but I suggest you to check better the documentation), in Python I am sure that there is no inlining, no tail recursion optimization and function calls are quite expensive.
Python functions are basically executable objects (and infact you can also define the call() method to make an object instance a function).
This means that there is quite a lot of overhead in calling them...
when you define variables inside functions, the interpreter uses the LOADFAST instead of the normal LOAD instruction in the bytecode, making your code faster...
Another thing is that when you define a callable object, patterns like memoization are possible and they can effectively speed up your computation a lot (at the cost of using more memory). Basically it's always a trade off.
Function calls cost also depends on the parameters, because they determine how much stuff you actually have to copy on the stack (thus in c/c++ it's common practice to pass big parameters like structures by pointers/reference instead of by value).
I think that your question is in practice too broad to be answered completely on stackexchange.
What I suggest you to do is to start with one language and study the advanced documentation to understand how function calls are implemented by that specific language.
You wil be surprised by how many things you will learn in this process.
If you have a specific problem, make measurements/profiling and decide weather it's better to create a function or to copy/paste the equivalent code.
if you ask a more specific question, it would be easier to get a more specific answer, I think.