The problem with simplified examples is that, being simple and straightforward, they don't press against the relevant sensory and cognitive limitations that we're trying to deal with by folding things into functions.
There's nothing in the example to justify why the whole thing wouldn't be written as one top-level block of code, with no use of functions whatsoever.
It's left to the expert reader to imagine a much more complicated example from their own experience - an example where it would no longer be sufficiently manageable to put everything in a single (and overly big) procedure.
One principle
I won't be able to be comprehensive about all the principles of how to structure programs well, but in my view the first principle is that, in a procedure which interacts with a user, you usually want user interaction coordinated at the top level.
This is for two reasons. Firstly, you want to be able to test the operation of the non-interactive parts with test arguments already given or with certain user inputs already assumed, so you don't want interactive code buried and intermingled with non-interactive code, otherwise every test run will require you to interact to get from one end of the test to the other (making manual tests tedious and thus deterring sensible testing to be done, and making automatic tests extremely difficult if not impossible).
Secondly, user interaction stages often have a cancellation, exit, or move backwards option, and this is very often supposed to have an effect on the top-level program flow. If you bury the interactive code, then difficulty and clutter is caused bubbling these cases back up to the top.
So the distinction between programmed processing on the one hand, and prompting/waiting for user input on the other, is sufficiently fundamental in my experience that you don't bury the two together.
And you typically try to avoid, as much as possible, alternating between user interaction and automatic processing. If you can get everything in one go from the user, then generally you do, and if you can give everything back in one go, then generally you do.
So it's typically not a new challenge to separate out interactive code, because it reflects a broader ergonomic principle of how software should be designed to interact with users and how users will find it most convenient to interact.
Another principle
The second principle is that reads should not generally be buried with writes (except writes done purely for logging and tracing purposes). This is basically "command-query separation". It should be made obvious at the top level of your method when things have moved from gathering data or planning changes, to storing data or making changes.
Again, there is likely to be a problem with any kind of testing when the two things are buried together. The results of the read from source cannot be performed without making changes, and the write cannot be tested with fixed test values.
But more importantly, it just makes the program considerably more difficult for the programmer to read the code and to analyse where data is coming and going overall, if there are deeply buried processes that both read and write with no sign of such a flow occurring at the top level.
Conclusion
In terms of your question about whether functions are given what they need or get it for themselves, you'd actually first need to divide between user-interactive and non-interactive parts of the program, and then also divide between parts which read and parts which write.
Obviously then, the parts which read must get things for themselves - that is their purpose. And the parts which write should always be given what they need, and what they need to complete that write should already be available to be given.
There are only some minor exceptions where reads might also write - as for logging - and where writes might also read - as with reading directly from the clock for timestamps.
It may also be acceptable to mingle reads and writes where the sequence is a write then a read. It is very acceptable when something is output to the user and their input is taken immediately in response to what has been put. And it is often acceptable when the write is the substantial action, and some kind of token or acknowledgement is returned.
These latter cases of write-then-read don't typically cause application-specific data flows to be hidden, or cause testing to be frustrated, though there could still be pathological cases where the marriage was inappropriate and the answer would be to split the two.