 My name is Mr. Sandesh Bharay, I am currently working as an assistant professor in the department of computer science and engineering at Valchand Institute of Technology, Sallapur. So in this video, we are going to focus on how to accept the user input in the Python. So before going to start this discussion session on this user input, let's see. Okay, what is the output or what is the outcome of this session? Okay, after this session, okay, you will be capable to accept the input from the user, okay, through the terminal. So let's start this session. What happens that there is some inbuilt method which is provided to accept the user input. Until now what we have done is that whatever the inputs, okay, we have to give that we have given by in the program only. Okay, but this makes our program very limited. Okay, so this should not be happened. So it should be robust. Okay, so user expects that it should accept the input from him. Okay, and it should work according to its inputs. Okay, so for that here in the Python, the special method input is given here. Okay, and through that we can accept the user input. Okay, so let's start to implement this one. Okay, what we have to do is that we have to write input function there. Okay, and actually, it is not mandatory to pass any arguments to this function one. Okay, but what happens that when we execute this file, okay, at the time, it will accept the user input and it is expecting the input from the user one. Okay, but user is not aware about that one. Right, so user will wait until any message conveyed to him and program will wait until any user input is provided. Okay, so this confusion may get created. So for that it is for our convenience and for user convenience, it is recommended to provide a certain message there. Okay, in the input function and that is passed as a parameter to this function one. Okay, so let's say we are going to perform here addition of two numbers and these numbers are accepted from the user here. Okay, so what you have to pass here that enter a first number. Okay, so this message is displayed on the screen and hence user will came to know that system is expecting input from the user one. Okay, so this is the general style to write the input function. Okay, this is accepting the fully first number. Okay, but for the addition, we need two numbers there. Okay, and for that, again for the second number, the same pattern will be repeated enter second number. Right, and obviously we are going to perform this addition of two numbers and for that we have to store it somewhere. Right, so for that what I will do is that I will use the two variables that is x is equal to input. Okay, a first number and y is equal to input the second number. Right, and after that we have to print the addition of these two numbers. So for that I will write here print x plus y. Right, so this is the general syntax to accept the user input. Okay, so we will execute this file and we will check whether it is working correctly or not. We will hope so it will work. Okay, let's save this file and let's execute this one. Okay, so at the bottom line you can see it is accepting the expecting the first number. Okay, so I will pass the five here. Okay, and it is expecting the second number now, so I will pass the seven here. Okay, and at the end you can see here that output is 57. Okay, so this will happen. Okay, so why it is happen because it is accepting the input in the string format. Okay, it is the default data type which is of the user input. Okay, and it is just concatenating that both the strings there. Okay, it is not accepting the user input in the integer fashion. Okay, so by default the value of the data type is the string data of the user input. Okay, so for this problem what we have to do is that we have to make a changes in this program. Okay, so we have to convert it into the integer format. Okay, so by default it is accepting into the string format. So for that here I will implement the type casting technique. Okay, so for this I will write integer of this input. Right, so it will automatically convert this into the integer format and after that again in the second value also. Okay, so I will implement the time casting. Okay, so now the both are converted into the integer format and we will hope it will work now properly. Okay, so for this I will execute once again and run module. Okay, it is again asking for the first number and again we will provide the same numbers. Okay, so I will pass the five as the first number and I will pass the seven as the second number. Okay, and as you can see then output that 12 is the correct result we have get. Okay, so this will happen when you are using the input function. Okay, so it will take the integer input in the string format by default. Okay, if you want to check it then you have to manually type cast it. Okay, so let's move to the here. Okay, so there is one question for you guys. Okay, what is the default data type in which Python accepts the input from the user and what are the different techniques which is used to resolve this issue. Okay, so think and try to answer this. So string is the default data type as we seen earlier that in which Python accepts the user input. Okay, if you want to change it then there are techniques which are called as the type casting. Okay, that we have seen earlier and second one is also the indexing term. Okay, the using indexing also you can change it. Okay, so we will check its demo. Okay, then you will come to know better. So what I will do is that I will remove all this stuff from here. Okay, just a second. Right, as we know the character input is not introduced in the Python. Okay, so we will try to implement that one. Okay, what I will do is that I will use this one variable which accept the character. Okay, and for that I will accept the user input as the character. Okay, so what I will do I will write here input just a second and here I am expecting the character input. So I will pass the message as the interact character. Right, and after that what I will do is that I will print as it is. Okay, no any complex code is there. Okay, I will write simply print ch. Okay, and I will save this file first and I will execute later. Okay, so it is asking for the character as per our estimation and I will pass now I will pass the one string there. Okay, I will pass the PQR there. Okay, I will not pass the character. So let's check what is the output. So the output is PQR. So it is not expected guys. Okay, why because we are accepting the character. Okay, so if string is passed then and then it is working properly it should not be happen like that. Okay, so propaganda is compromised here. So for that the second technique as we have seen earlier that we have to implement this to resolve that issue. Okay, so for that what we will do is that instead of printing the whole ch. Okay, we will accept only the first character. Okay, whether the user pass the string then only we will pass only the first character. Okay, I will we will ignore all the rest part there. Okay, for that we can write here the indexing term and you can do it likewise. Okay, so for this I will again run this file and as you can see it is accepting the character but we will pass the string here again. Okay, so I will pass the PQR and you can see the output is only the first character. Okay, so likewise in this fashion using the indexing term you can resolve this issue. Okay, but I just want to tell you one more thing that instead of writing here ch of 0 at printing statement. Okay, what is the problem in that one is that you use the indexing at time of the printing but ch is still storing the whole string here. Okay, so it should not be happen. We will accept only the first character. Okay, we will store only the first character. Okay, so for that what I will do is that I will remove the indexing from here and I will use the indexing at the input only. Okay, so whatever input we have accepted and at that time only we will accept the only first letter. Okay, so now obviously ch will contain only the character and we will print the ch. Okay, so it should not be changed the output. Okay, so let's check what is the output and it is again asking for the character I will pass the string again. Now it say the value of the ch is the p. Okay, it means you are reducing the storage here. Okay, I know it is negligible but it's okay. Okay, so in this fashion you can use the typecasting and indexing technique to change the default data type. Okay, which is the string data type by default. Okay, so this is it regarding the user inputs. Okay, so these are some references I used to make this video. Thank you.