 Here's a variation of our Agent Days program that has a variable for the user name and gives a personalized message as its output. When we run the program it works great, but it's inflexible. If someone isn't named Maria, or isn't 27 years old, and next year Maria will be 28, we have to rewrite the program. What we'd like is a way for the user to be able to run the program and give us the information rather than having to modify the program every time they want to see different results. The way we do that is with the input function. I'm going to use the input function here instead of the name Maria by saying input. In the parentheses I'm going to put something called a prompt. It's the question I'm going to ask the user. When it's a string, what is your name? When Python encounters line 6 and finds the assignment operator, we work out the right-hand side first. That will call on the input function to do its thing. The input function puts the prompt up on the screen and then waits for you to type something. Let's run the program and this time I'll type my name David. The string I typed gets assigned to the name variable and that's what gets printed out. Let's run that program again. This time I'm going to say my name is Fum and again I've personalized the name by asking the user for input. I want to run the program one more time and point something out. Notice that the cursor for the input is right up next to the question mark and that looks a little bit ugly to me. I usually like to put a blank before the closing quote mark and that blank will show up on the screen. When it does it'll give the cursor some breathing room between the prompt and where the user will type their input. Running it again it's going to ask what my name is and this time I'll put in Federica and now you can see the space between the prompt and where I'm going to start typing. So far so good. Let's do the same thing for years. Instead of always using 27 we'll use the input function to ask the user how old are you and we'll put the blank in there again to give the cursor some space. Let's run the program and we'll say that Martin is 20 years old whoa what happened there? What happened there is strings. Whenever you do input the result of the input function is always always always a string. When we asked how old are you instead of getting the number 20 we got the characters 20 and 0 and that's what years are referred to on this line here. When we evaluate the right hand side of line 8 we're multiplying a number by a string and when you multiply a number by a string it repeats it that many times and that's why we got 365 repetitions of the string 20. How do we get around that problem? The answer is conversion to integer. Here's an integer so what we will say is we want the integer conversion of whatever input gives us. What we have here is a function call inside a function call. Let's go through this in detail to see what the computer's doing. When Python sees this line with the assignment operator it knows that it has to figure out what the right hand side works out to. The inner function call happens first. It does the input call which puts up the words how old are you and I typed in 20. That gives me back the string 20 and that is what goes into the int function and I get a number 20 as the final result of the right hand side which means years will refer to the number 20. Let's run the program again with this change and we'll have Martin be 20 years old and now it works properly. We get a reasonable result because we've converted the string from input into a number which is what we really want to use for multiplication. It's easy to forget this conversion. If it happens to you you won't be the first person who's ever done it and you won't be the last person either. I've known some beginning programmers who look at this and say function calls inside of function calls that's a little weird. I'd like to do it in two steps. We can do that by doing the input first into a string. We'll say years string is input of how old are you. Then we'll do the conversion separately. We'll convert years string to an integer. It's one extra step but if it helps you understand what your program is doing then do it that way. You'll see that it has the same results. If someone named Helen who's 45 uses our program she'll get the correct answer also. Let's give the money saved program the same treatment. For added flexibility we'll ask the user for input. The program description is exactly the same but in this case instead of saying that the amount is $19.95 we're going to ask for input and let's do it in two steps. We'll say the price string is going to be input and the prompt will be what is the price and a dollar sign. In this case I'm not putting an extra blank before the closing quote because having the cursor right up next to the dollar sign looks really good. Then the price will be the floating conversion of our price string. Remember this has to be floating point because money can have decimal points. I'll do the percentage with nested function calls. I'll take the float of whatever input gives us and the prompt will be what is the discount percentage. Let's run the program. When I test it I like to use numbers where I know exactly what the answer is going to be in advance to make sure everything's working properly. If something costs $50 and I have a 10% discount I should get $5 and that's what happens. This gives me confidence that the program is working correctly. I can run this program again with any price and discount I want. If something costs $25.99 and I have a 3.25% discount I'm saving $0.84. Let's return to the age program for our summary. The input function displays a prompt on the screen, waits for the user to type their answer and press enter and whatever string they entered is returned to you. If you want a string such as the name leave it as a string. If you need an integer or a float remember to convert it otherwise your arithmetic is not going to work out the way you thought it would.