WEBVTT 00:00.710 --> 00:07.490 Hello again let's now have a look at how we can take an input from the user and tell the user to input 00:07.490 --> 00:16.830 something to give me back something and then and then as a result I would get some I would get something 00:16.950 --> 00:21.310 in such a way that I could operate on the same right. 00:21.480 --> 00:25.910 So let's take an input from the user navigating an input from the user. 00:26.250 --> 00:30.350 We need to use a built in function which we will just have a look at. 00:30.360 --> 00:33.420 So let's go back to the documentation how will we go. 00:33.570 --> 00:38.640 We can go from here itself and the help we can get to Python docs but when we open inviting docs from 00:38.640 --> 00:45.470 here it will open up in the in the browser which is on the Raspberry Pi. 00:45.780 --> 00:51.660 And because it the Raspberry Pi it can take a lot of processing whenever you open a browser and if you 00:51.660 --> 00:58.260 do not want to do that and you open a browser on the Raspberry Pi and if you're doing it on a computer 00:58.440 --> 01:05.120 if you have open the screen of the Raspberry Pi on your VNC OK. 01:05.700 --> 01:07.980 For now I'm just bringing it out. 01:07.980 --> 01:15.210 I'm coming back into the Windows environment outside and after coming here I just need to check with 01:15.600 --> 01:24.130 the documentation so I will go here and I will just see right there the documentation for for. 01:24.190 --> 01:30.380 So Khaitan docs are quite in docs and then I'll get that. 01:30.380 --> 01:36.340 So three points explain for documentation the Library Reference the built in functions and in the bill 01:36.340 --> 01:37.660 that functions. 01:37.670 --> 01:40.830 Let's have a look at a function that can help us out. 01:41.420 --> 01:48.170 Let's say the function that can help us out in taking an input from the user is going to be the input 01:48.170 --> 01:48.920 itself. 01:49.190 --> 01:58.200 OK so let's take an input from the user and anti-graft from the user Solange's full screen. 01:58.430 --> 02:07.530 Also if file new fire OK I'm going to take an input from the user now input function input. 02:07.540 --> 02:11.000 Now what does input function require. 02:11.020 --> 02:14.600 As a parent or what does this command requires a part of. 02:14.710 --> 02:18.640 Let's have a look once again exit and come here. 02:18.760 --> 02:26.500 Click on input or input click on input requires an optional bottom Eido the paramita that is there. 02:27.310 --> 02:28.730 What is the meaning of prompt. 02:28.930 --> 02:31.160 Which means you can give a prompt. 02:31.180 --> 02:36.220 Or you can ask something or it can tell something the user to enter. 02:36.400 --> 02:41.650 So that means I can say here enter number. 02:42.200 --> 02:44.100 I can tell it as a string. 02:44.540 --> 02:53.510 Now when you tell this to when you tell this to him this input function is going to execute it and then 02:53.510 --> 02:57.840 put function is now going to wait for the user to enter something. 02:57.860 --> 03:01.740 Now comes onto the user and does something. 03:01.850 --> 03:11.270 The input function will not mind my words without the user entering something the input function will 03:11.270 --> 03:20.410 not leave this particular execution line which means the execution will not go forward. 03:20.810 --> 03:23.500 This input function will block the code out there. 03:23.810 --> 03:26.450 Wait for the user input when the user input. 03:26.510 --> 03:27.910 Then it will go ahead. 03:28.250 --> 03:32.070 So now when the user gives you an input you need to store it somewhere. 03:32.090 --> 03:34.760 You need to store it in something called as a variable. 03:34.760 --> 03:39.680 So let's start adding a variable that say some and let's do some. 03:39.700 --> 03:44.560 The minute the user enters something I have stored that in whatever the user has entered. 03:44.710 --> 03:47.000 All I need to do is I need to print. 03:47.380 --> 03:52.980 Let's say that numb multiplied or oh you multiplied. 03:54.190 --> 03:57.520 By let's say 10. 03:57.520 --> 04:03.840 So if I enter 5 The answer should be ideally what 50 should be. 04:03.950 --> 04:04.840 Should be 50. 04:04.840 --> 04:06.380 Let's see if that is the answer. 04:07.490 --> 04:15.380 Save let's say save it as inputs use a call. 04:15.510 --> 04:21.430 Now I'll run this function of five it saves engine number. 04:21.430 --> 04:24.280 All right I'll enter a number let's say five. 04:24.520 --> 04:26.710 Ideally Unza should be 50. 04:26.860 --> 04:28.470 But what's the answer. 04:28.870 --> 04:31.000 5 5 5 5 5 5. 04:31.000 --> 04:32.020 How many times five. 04:32.020 --> 04:39.330 One two three four five six seven eight nine 10 oh printed five ten times. 04:39.530 --> 04:43.270 But I called you were. 04:43.650 --> 04:45.210 But I thought it was a number. 04:45.370 --> 04:46.390 Let's see. 04:46.390 --> 04:54.970 No it's not a number because if I ever put it in that type Wolf number of the number that I've gotten 04:54.970 --> 05:01.960 that use to see that type what that type of number got the user function f 5 once again. 05:02.200 --> 05:05.840 What is the number that I got from the user or type of. 05:05.880 --> 05:07.090 It's a string. 05:07.090 --> 05:14.820 So that means whatever the user enters the input function takes it as a takes it as a string. 05:14.840 --> 05:22.340 So whatever the user enters the input function takes it a string which is not which which then that 05:22.340 --> 05:24.500 string gets multiplied ten times. 05:24.500 --> 05:28.430 That means that string was five it got printed 10 times. 05:28.600 --> 05:38.720 OK so maybe you do not know this but if there is a string which is let's say hi and if that string is 05:38.720 --> 05:43.130 multiplied 20 times it will print hi 20 times. 05:44.290 --> 05:45.570 OK that means. 05:45.630 --> 05:50.390 So basically that's the same thing what's happening when you multiply the string 10 times. 05:50.490 --> 05:52.340 It just printed 10 times. 05:52.490 --> 05:52.750 OK. 05:52.770 --> 05:54.330 But when I thought this was the number. 05:54.390 --> 05:55.320 No there's not a number. 05:55.320 --> 05:57.440 This is a string all. 05:57.480 --> 05:59.140 So what should I do. 05:59.220 --> 06:05.240 Which means whatever the user inputs whatever the user inputs I need to convert it. 06:05.340 --> 06:13.650 So whatever the user inputs that means the input function is going to return to me a string and died 06:13.660 --> 06:16.030 and would return to me a string. 06:16.050 --> 06:23.490 Now whatever the user gives me or whatever the user gives me that is stored in a string when I get an 06:23.490 --> 06:23.940 input. 06:23.940 --> 06:31.230 But then I need to before storing it and I need to convert that into when responding in the future I 06:31.230 --> 06:35.420 need to convert it into an integer because I know that fiber is going to be a number. 06:35.430 --> 06:39.480 I know that the user has to enter an number what should I. 06:40.830 --> 06:42.200 Relate to. 06:42.450 --> 06:49.380 I will then again go back to that documentation and check if there is a built in function which can 06:49.380 --> 06:53.140 convert a string to an individual. 06:53.640 --> 06:56.860 There is there is a built in function calls in. 06:57.400 --> 06:58.820 And what does it do. 06:58.830 --> 07:07.360 It returns in Peter object constructed from a number or a string of X or its returns zero if not humans 07:07.380 --> 07:08.830 are given. 07:08.850 --> 07:09.860 All right. 07:10.290 --> 07:16.820 So I need to create a number I need to create whatever is input from the user. 07:17.100 --> 07:24.630 That should be considered when in danger by putting the entire operation into. 07:24.690 --> 07:32.000 And in the bios so that whatever is input from the user is muddle into any teacher and then shouldn't 07:32.000 --> 07:32.350 do. 07:32.480 --> 07:38.780 Well now if I type in the type of number and if I print the number multiplied by 10. 07:38.940 --> 07:40.880 Let's see is the answer. 07:40.950 --> 07:45.740 There are number five type of numbers class and. 07:45.990 --> 07:49.560 So there's 50 Zappia. 07:49.740 --> 07:51.870 So you have five tens or 50. 07:52.080 --> 07:57.410 So this is about an integer is about taking an input from the from the user. 07:57.690 --> 07:58.290 All right. 07:58.410 --> 08:02.820 So you take an input from the user and then do a particular approach. 08:03.060 --> 08:08.420 Now if you want you could have done something like this for a previous file that we had already done 08:08.470 --> 08:15.870 let's say operators instead of saying is equal to 7 and B is equal to 3 You could have told you could 08:15.870 --> 08:18.010 have told the user to enter it. 08:18.030 --> 08:26.310 You could have said is equal to input and of value for me. 08:26.950 --> 08:28.130 OK. 08:28.320 --> 08:34.370 And because this input will take it as a string I should convert it into n in Dejah. 08:34.930 --> 08:35.700 Correct. 08:35.820 --> 08:41.580 And then I should have another value which is entered a value for B 08:44.750 --> 08:49.750 correct than what it is stored in B and then it should be in the NBA and it should. 08:49.970 --> 08:53.240 And it should be in the plus and minus B is a multiplier would be. 08:53.240 --> 08:55.300 And so one save. 08:55.370 --> 09:10.850 And if I run this interval for a let's say let's say 45 and up and a rally for B save Phife enter call. 09:11.040 --> 09:16.810 So you have a plus 50 minus 40 multiply babies to 25. 09:17.140 --> 09:21.690 Well baby's nine point zero a blah blah. 09:21.840 --> 09:22.320 Yeah. 09:22.440 --> 09:28.020 So you have quite a lot of things to do when you take an input from the user. 09:28.020 --> 09:31.420 All right let's get back into the mode. 09:31.440 --> 09:37.110 OK so this is how you take an input from the user and you will do a particular operation. 09:37.110 --> 09:40.280 So we saw that with the medical practice player. 09:40.410 --> 09:47.850 All right in the next video we go on to something called a selection statement or let's see how to how 09:47.850 --> 09:53.590 to make a statement or select or make a decision when we have to clear.