Short answer
Each time Python "sees" fibonacci() , it makes another call to the function and does not move on until it completes this call to the function.
Example
So let's say he evaluates fibonacci(4) .
As soon as it gets into the string return fibonacci(number-1) + fibonacci(number-2) , it "sees" the call to fibonacci(number-1) .
So now it works fibonacci(3) - he hasn't seen fibonacci(number-2) yet. To start fibonacci(3) , he must find fibonacci(2)+fibonacci(1) . Again, it launches the first function that it sees, this time fibonacci(2) .
Now it finally gets into the base register when fibonacci(2) is executed. It evaluates fibonacci(1) , which returns 1 , then for the first time it can continue part + fibonacci(number-2) calling fibonacci() . fibonacci(0) returns 0 , which then returns fibonacci(2) return 1 .
Now that fibonacci(3) received the value returned from fibonacci(2) , it can go on to evaluate fibonacci(number-2) ( fibonacci(1) ).
This process continues until everything has been evaluated and fibonacci(4) can return 3 .
To see how the whole assessment goes, follow the arrows in this diagram:

Matthew adams
source share