Run the cell above the one showing an error first, and then
function2(2) should work.
The lack of a number in the bracket next to
In of the cell where you wrote code to define your function indicates you never ran that cell. So when you try to run the cell you see as the 21st cell you have run in the notebook (indicated by the
In  ) , it gives the error you see.