1 00:00:00,420 --> 00:00:01,070 Hello everybody. 2 00:00:01,170 --> 00:00:02,460 And welcome back. 3 00:00:02,670 --> 00:00:09,900 And right now let's see how we can actually import some oil or some of the older the used libraries 4 00:00:09,900 --> 00:00:11,640 that come in Python. 5 00:00:11,640 --> 00:00:14,670 So let me just throw this. 6 00:00:16,140 --> 00:00:22,230 You might have noticed that sometimes in my Python interpreter I actually clear my screen now that he's 7 00:00:22,320 --> 00:00:28,890 using the input function which actually imports the OS library which allows me to run a terminal commands 8 00:00:29,310 --> 00:00:30,490 in my program. 9 00:00:30,720 --> 00:00:34,770 So let me just show you how you can do that so you can just type your anything. 10 00:00:34,770 --> 00:00:36,030 Doesn't even matter. 11 00:00:36,030 --> 00:00:41,520 And then once you want to create for example the screen you can just import the OS which is the library 12 00:00:41,520 --> 00:00:48,000 for the operating system and then you can just use that or use the functions in that library to create 13 00:00:48,030 --> 00:00:48,810 to clear the screen. 14 00:00:48,840 --> 00:00:58,230 So one of them is always a dot system which basically in this always in this OS library uses a function 15 00:00:58,230 --> 00:01:03,270 called system which specified in the brackets specifies the command that we want to run. 16 00:01:03,300 --> 00:01:09,090 So in my case clear and wants a president you can see that it actually clears the screen. 17 00:01:09,150 --> 00:01:14,070 You can also run any other command doesn't have to be clear so you can just type your unless and you 18 00:01:14,070 --> 00:01:19,980 can see that will it will actually list all the files in my current system directory or part of I mean 19 00:01:19,980 --> 00:01:24,860 my current python programs directory which are these six programs. 20 00:01:24,870 --> 00:01:27,230 So these can be also useful for us. 21 00:01:27,270 --> 00:01:30,030 That is a simple use of importing a library. 22 00:01:30,030 --> 00:01:31,770 Now you can also do something like this. 23 00:01:31,770 --> 00:01:41,430 So let me just close this nano import import by let's actually call it along. 24 00:01:41,460 --> 00:01:41,980 Let's save it. 25 00:01:41,990 --> 00:01:45,560 Not knowing why we actually type here. 26 00:01:45,660 --> 00:01:50,230 User when I write on. 27 00:01:50,440 --> 00:01:50,780 OK. 28 00:01:50,810 --> 00:01:58,670 So right now we can add a simple function which is called adding num number one and number two. 29 00:01:58,670 --> 00:02:05,270 Now this is just a function that will add two numbers and store it and print the result of those two 30 00:02:05,270 --> 00:02:09,580 numbers so print and online plus name two. 31 00:02:10,520 --> 00:02:18,290 Well let's put it as an integer so it should print the integer of these two numbers so let's do it like 32 00:02:18,290 --> 00:02:19,040 this. 33 00:02:19,070 --> 00:02:25,460 Now basically you can just save this file just remember the name of the function which is adding You 34 00:02:25,460 --> 00:02:26,350 can save it. 35 00:02:27,290 --> 00:02:33,920 And we can see if I see it's not that important why this program doesn't really do anything it just 36 00:02:33,920 --> 00:02:38,310 closes runs the program doesn't print out anything and then closes the program. 37 00:02:38,310 --> 00:02:40,920 That's because we only have one function in it. 38 00:02:41,030 --> 00:02:45,080 But let's now run our normal program. 39 00:02:45,320 --> 00:02:54,300 So let's not on Python 7 by user being python and let's import our import. 40 00:02:54,530 --> 00:02:58,460 Now that could be a problem since our import is called import. 41 00:02:58,460 --> 00:03:00,470 So let's actually rename it. 42 00:03:00,590 --> 00:03:02,720 I thought that would be a problem. 43 00:03:02,960 --> 00:03:13,150 We control though let's call it I m b r t so we can actually depreciated from the command import itself. 44 00:03:13,150 --> 00:03:14,760 So finding the right. 45 00:03:14,770 --> 00:03:15,870 Yes and then we close. 46 00:03:15,870 --> 00:03:18,300 So right now we have once again. 47 00:03:18,960 --> 00:03:19,260 OK. 48 00:03:19,270 --> 00:03:26,710 So we remove the import function by or pardon me the import program the pie then when we see mode the 49 00:03:26,740 --> 00:03:27,960 import apply. 50 00:03:28,260 --> 00:03:34,630 And now we have our imports by with a simple adding function that we want to use in our other program 51 00:03:34,660 --> 00:03:36,150 which is Python 7. 52 00:03:36,610 --> 00:03:40,600 So let us open five to seven by now let us continue. 53 00:03:40,600 --> 00:03:45,280 So right here you can basically just do this. 54 00:03:45,280 --> 00:03:57,190 So a equals the raw inputs and we want to integer right here since we want to specify a number so first 55 00:03:57,190 --> 00:04:04,760 No this is something that we already covered the equals integer raw input. 56 00:04:04,870 --> 00:04:06,460 Second number. 57 00:04:07,820 --> 00:04:15,490 And right now all we have to do is specify adding a map a comma B. 58 00:04:16,110 --> 00:04:23,410 And right now what we have to do is import input and then we can use the function that we specified 59 00:04:23,410 --> 00:04:32,560 in a different code by Cat by 10 7 vote buying or to see if everything you said correctly we have our 60 00:04:32,560 --> 00:04:36,820 adding function from a different program which is by the user input for two numbers. 61 00:04:36,820 --> 00:04:40,800 And we imported our library which is this program right here. 62 00:04:40,840 --> 00:04:46,340 So right now all they have to do is see each month despite seven to be an executable and we can run 63 00:04:46,340 --> 00:04:51,480 it by seven so three three named adding is not defined. 64 00:04:51,490 --> 00:04:52,930 Yes of course I forgot. 65 00:04:52,930 --> 00:04:59,620 So right now in order to use this function you actually have to specify the name of the file itself. 66 00:04:59,630 --> 00:05:05,950 So you cannot just use adding since that would be a function that is defined in this program went to 67 00:05:05,950 --> 00:05:11,860 specify from which library or from which program we use this function and in our case we use it from 68 00:05:11,860 --> 00:05:13,150 the from this function. 69 00:05:13,150 --> 00:05:22,240 So we have to specify down here input dot adding which will report to so python will know that it should 70 00:05:22,240 --> 00:05:27,810 look for this adding function in this library right here that the three important that we imported. 71 00:05:27,820 --> 00:05:33,830 So just delete this and let's save this right now. 72 00:05:33,830 --> 00:05:35,420 And right now it should work. 73 00:05:35,450 --> 00:05:43,460 So Python 7 3 4 and we get 7 as a result as we can see we were able to use a function that we didn't 74 00:05:43,460 --> 00:05:48,860 use in our own program in order to execute a simple adding of two numbers. 75 00:05:48,890 --> 00:05:50,780 So that is how it functions. 76 00:05:50,950 --> 00:05:52,630 Me That is how important works. 77 00:05:52,640 --> 00:05:54,600 And that is why it is so useful. 78 00:05:54,600 --> 00:06:00,470 So basically we can use any program that anyone before us called it and we can use the functions from 79 00:06:00,470 --> 00:06:07,400 those programs in order to help us build our own program faster or basically if someone already coded 80 00:06:07,400 --> 00:06:12,290 something that we need we do not have to code it ourselves we can just download that program and use 81 00:06:12,290 --> 00:06:13,970 it as we like. 82 00:06:13,970 --> 00:06:18,800 So that will be about it for the importing libraries. 83 00:06:18,800 --> 00:06:22,490 It is very simple so you just find a library you want to import. 84 00:06:22,490 --> 00:06:28,760 You need to put it into the same directory as your program and then you just type up her up at the beginning 85 00:06:28,760 --> 00:06:31,610 of the program import and then the name of the library. 86 00:06:31,760 --> 00:06:36,380 After that you need to specify any function with just the name of the library dot and then the name 87 00:06:36,440 --> 00:06:37,700 of the function. 88 00:06:37,700 --> 00:06:39,610 So pretty simple. 89 00:06:39,740 --> 00:06:45,010 So that be about it for this tutorial in the next one and probably the last line of Python basics. 90 00:06:45,020 --> 00:06:50,210 We will cover the creation of files which is something important we will learn how we can create files 91 00:06:50,240 --> 00:06:53,570 delete files right to files and read from files. 92 00:06:53,570 --> 00:06:58,730 So that would be allotted for this tutorial and I hope I see you in the next one by.