So, welcome up to the Python posts and today let us start doing a program by taking input from the user. So, how to do that. Now suppose here I am creating a variable called n. So, n will be equal to input and then I will write here what is your age? Now, whenever I will write this and I will submit this program, I'll run this program what it will show. So, see what it's asking. It's asking me, what is your age?
It is just showing you a space to write something over there. So suppose I'll write 30. So what is your age? It's asking, so I've provided 30 and I've just pressed enter. So, this is the result. So, what is your age 30.
So, here by using this input function, we can use input from the user. Now, suppose I will write here and the same thing I will write n equal to input, what is your age and then after that, I write, print and here I am write my name, sorry, my age is an outside this code I write in. Now what will be the result? Just run it and see what you get. So, it's asking for the age Now, right, it's 26 and I press enter. So what it gives it gives my age is 26.
So what is happening here? It's basically asking you input, so it's basically asking user to give an input and it will execute in the same way. So, what happening here is whenever it asking for a particular input, what I am providing it, the first time I provided 30, the next time I provide it 26. So, what this is 30 what this 26 is, this is the value of that particular variable in so whenever I'm providing a particular value, it is assigning this particular value to the variable in and then it is just executing the next code accordingly. So whenever I wrote here 30 it is it just assigned 32 n and then again when 26 over here, it assigned this value 26 to In and just print the next statement that is my age is 26. So let us just write in a different way.
So in input so now I'm writing What is your name? Okay, now, in the next steps, I write, print and write hello and give a comma outside quotes and write end over here. Then again give a comma and here I'll give an explanatory sign. Now what it will happen I will write another print statement. So print now I'll write How are you n again, give a comma and within this a writer, question mark because this is a question now in the next day, I will again write a print statement. Now here own right.
I hope life is treating an outside this course leave a coma, right? And again give a coma, right? Give a code and write well. So here now will be a full stop. And I will execute this code. Now what will I get?
Can you guess what I can get in the place of n, I didn't get the value that I will input. So if you don't understand what result will I get, just execute it and see the result and you will understand it very well. So just execute it. So the first thing what it will ask is for is your name. So I'll just write my name over here. So I'm writing my name.
You press enter and see what it does. It just printed the value of that particular n to the every print statement where n is assigned. So what is your name? Reporter? Hello Ruth Aparna. How are you read the corner?
I hope life is treating Ruta borna. Well, so, every time you will assign a new value to that end, you will get a new result to suppose the same thing, I will just copy it and paste it over here. Now, if I execute this code and write a different name here, suppose I write here, submit. Okay, now just press Enter. Now what happens? It just changed the value of n to submit.
So what I got what is your name summit? Hello, summit. How are you summit I hope life is treating summit well. So every time you give an new value to the input statement, it will assign that particular value to the end and it will execute the next steps. accordingly you have learned how to use in how to use or how to get input from the user. So this input function will help you to get input from the users and then it will execute the next steps.
So I'll be ending my video over here. See you in the next video. Thank you