Work on this very important lecture and this lecture you learn how to make your script interact with
the user and the user is someone who you can give your adult program and they can execute it easily.
This is done by integrating some code that makes possible interaction with the user.
So in this lecture I'll teach you how to receive user input for your program.
Another program can process these user input.
So let's build a simple function here.
Let's say Miles to kilometers.
This function will get Mols as input and that it will convert this Miles to kilometers.
So Miles is a parameter and I know that one kilometer is equal to 1.6 zero or nine three 4 miles.
So we multiply miles with that number about what we want to do with the altitude is printed out on screen.
So print a kilometer variable.
Now let's call a function the way we are used to.
So so kilometer and we pass an argument here and we get an output.
However a better way to call the function to generate an output would be to integrate an input function
inside the script.
So the input function is a function that implements user interaction feature.
So the idea is the input function will also allow the user to enter some input and it will give input
entered by the user to pass it as an argument to the function.
So this is the idea we want to store the input that will be entered by the user in a variable.
So lets say M which stands for miles to be equal to the input function the input function takes an argument
which is the message that you want to show to the user.
So lets say they use and 2 miles and put a call of there to give it a nice Fluke and that's it.
And then what we want to do with this variable is pass the test and argument to the Massud kilometer
function.
So we just go ahead and call the function here and pass the variable as an argument.
So if I said lets go ahead and around this program now.
So the program is also going to add a value for the Miles.
Go ahead and type in 100 here.
And press enter and we get an error.
So why do we get an error.
We're getting an error because Python is trying to multiply a string with a fourth number.
So we enter 100 which is seemingly a number.
But however the input function reads everything that you pass to be treated as a string.
So in this case it gets a Number One hundred and converts to two string and it passes to the function.
So that's why we get an error.
So we want to convert this given input from the user from a string to a float type to do that.
You just go ahead and type M equals float and so what this does is it just gets current value of converts
to flawed data.
Now let's go ahead and run the program.
OK.
We are asked to any of the models let's say 100 and we get the output.
So the Z idea of the user interaction the program asks the user to enter in both valid as input and
then is the output.
Now we can publish the program even more.
We can print out a kilometer stream beside the value just like this.
So we add a call and a string.
So the print function that we print out to values if we execute the program again and or some models
and error escapes you get the value and I'll label one last thing I want to show it to you is that you
don't have to use slider for executing a program.
You can also execute a program using your command line to do that.
You should type the program which you want to exit the program with hogi.
So the program is Python have a python program you want to execute is adopt twice creep.
So you enter the path of your data by script and press enter.
Now Vanesa user you just follow the instructions of a program and you finally get the ultimate.
So that's how you can interact with the user and get the user input and processing in your programs.
Talk to me in the next lecture.