Python 3.2 : Function

We will continue with our code and we will make the functions when we look at our code we see that it has three parts we have asked for the age the first part, ask for the name the second part and display the results the third part, and if we want to do well and improve our code we can put this in a function that we can call ask for age if I do like this it's calling a function and to declare a function or define function I need to put, a def in front of it I put a colon and I'm going to put all this code inside by making a tab and after that I'm going to call my function to do this I have to write the name of the function defined above so ask age and don't forget the brackets if I do it this way you see at this level there is an error it's really because the age is declared locally in the function and not globally I'm going to put at this level equal age if I put it like that and I put the cursor I'm told that the age I defined at the bottom is the same as the age at the top this underline if I change the name here and I put earlier init I change and I do a return of age init you see that it's good I can now launch my program what is name titi 23 you see that my program works normally now if I want it is a debug to see how this code executes I will come at this level at the level of the call of the function to put a button debugger and to launch the function blocks level when it arrives there is asked the name the function input therefore I must put a name I will put titi when I put Titi that arrives here I must not click here because if I know that that is going to just continue to execute the code normally in what we would like to be This code enters the function and starts to execute it so that we have to type here you see it starts to execute and now we can type here we can type here and so on it is blocked at the level of input we have to enter the age we continue everything works normally Well we say to each other very soon for the emergency box of functions.