1 00:00:00,120 --> 00:00:07,020 Hello welcome to this tutorial on the mad module when writing Python programs. 2 00:00:07,020 --> 00:00:11,250 We might have to perform mathematical operations frequently. 3 00:00:11,250 --> 00:00:20,270 Say for example calculating the square root of a number are finding the factorial of a number etc.. 4 00:00:20,640 --> 00:00:30,360 Python provides the standard library that simplifies the programming process and removes the need to 5 00:00:30,360 --> 00:00:34,770 read write commonly used functions are operations. 6 00:00:35,010 --> 00:00:42,940 The python standard library is a collection of modules accessible from other programs. 7 00:00:43,230 --> 00:00:52,590 The libraries are modules provide us with useful data types functions and tools. 8 00:00:52,800 --> 00:01:01,380 So if we make of a program's use the existing library module the development process will be much more 9 00:01:01,380 --> 00:01:10,600 comfortable and great and the python library is part of a very standard Python installation. 10 00:01:10,600 --> 00:01:19,230 And if you want to use these library modules you need to call them or import them into your python programs. 11 00:01:20,660 --> 00:01:29,330 You need to have what is known as an import statement in your program in order to access the functions 12 00:01:30,040 --> 00:01:35,600 or are other tools or data types defined in these modules. 13 00:01:35,600 --> 00:01:44,060 In this tutorial we're going to discuss about the map module and we will see how to access the functions 14 00:01:44,060 --> 00:01:46,310 defined in this module. 15 00:01:46,310 --> 00:01:54,590 The math module provides a lot of useful functions that we will now see in order to access these functions 16 00:01:54,590 --> 00:01:55,830 and the tools. 17 00:01:55,840 --> 00:02:03,950 Defying any math module we need to import this module and this is this statement the import statement 18 00:02:04,190 --> 00:02:10,610 that we need to put in our python program in order to access these functions in this module. 19 00:02:10,610 --> 00:02:17,490 Now say for example you want to access a method name Eskew Artie. 20 00:02:17,720 --> 00:02:27,460 This is the method name is Q. Artie and this method our function is used to get the square root of a 21 00:02:27,460 --> 00:02:28,270 number. 22 00:02:28,770 --> 00:02:33,190 And this function is defined in the math module. 23 00:02:33,190 --> 00:02:43,930 Now in order to access this function in your program you need to use the dot operator so mad dot function 24 00:02:44,590 --> 00:02:49,050 name and you specify the number here. 25 00:02:49,330 --> 00:02:57,490 So for example a you pass it as an argument see the dot notation is a way we connect the name of the 26 00:02:57,490 --> 00:03:03,960 object in a our case it is the math module to the name of the method. 27 00:03:04,060 --> 00:03:08,530 It can perform the math module has by as a constant. 28 00:03:08,530 --> 00:03:13,940 That can be used in mathematical calculations such as calculating the area of a circle. 29 00:03:13,960 --> 00:03:24,160 Now in order to access this the constant pi from our python programs you can use the dot notation here 30 00:03:24,190 --> 00:03:24,760 as well. 31 00:03:24,820 --> 00:03:36,140 So you're going to access this constant by using the dot notation like this so we will now see how we 32 00:03:36,140 --> 00:03:44,360 can access the functions from our Jupiter notebook or the python programs so in order to access the 33 00:03:44,360 --> 00:03:49,610 math module we need to first import this module into our programs. 34 00:03:49,610 --> 00:03:52,650 For this we use the import statement. 35 00:03:52,750 --> 00:04:00,110 We are going to have a detailed discussion on import statements in the coming up sessions. 36 00:04:00,110 --> 00:04:07,040 So for now in order to access any of these standard libraries the python standard libraries you can 37 00:04:07,040 --> 00:04:16,460 use the import statement like this and then execute this line in order to see the contents of the library 38 00:04:16,460 --> 00:04:17,610 module man. 39 00:04:17,630 --> 00:04:24,290 We can use the help function to let us pass the math module to the help function. 40 00:04:24,740 --> 00:04:32,680 So here you see the list of the different functions and tools that are available in this module. 41 00:04:32,700 --> 00:04:41,110 Now let's access some of these functions from our python program Firstly let us access the constant 42 00:04:41,140 --> 00:04:44,150 pi from our program using the dot notation. 43 00:04:44,800 --> 00:04:48,770 So here is the value of the content by next. 44 00:04:48,790 --> 00:05:00,410 Let's call the function square root as you are d default name and let's pass an argument to this function. 45 00:05:00,580 --> 00:05:02,980 Sixteen so here. 46 00:05:03,160 --> 00:05:09,420 This function in the math module has calculated the square root of the number and return the result. 47 00:05:10,120 --> 00:05:18,040 We can also calculate the factorial of a number using the function factorial defined in the math module. 48 00:05:18,520 --> 00:05:24,240 So let's pass the argument 5 to this function and then execute this line. 49 00:05:24,580 --> 00:05:33,630 And this function has returned the value 120 it is the factorial of the integer value 5. 50 00:05:34,050 --> 00:05:41,830 Now let's call two functions that are related to rounding the same function and the flawed function. 51 00:05:41,970 --> 00:05:48,570 They still function returns the next integer bigger than the given number. 52 00:05:48,870 --> 00:05:55,860 So in other words the method sealed returns the smallest integer bigger than the given number. 53 00:05:56,340 --> 00:06:00,120 So let's execute this line and see the result. 54 00:06:00,900 --> 00:06:08,450 So it has returned the next integer bigger than this number minus 2. 55 00:06:08,460 --> 00:06:19,850 Next we will pass a positive another floating point about the dot 0 5 to this function C though the 56 00:06:19,890 --> 00:06:26,800 value return now is 4 because 4 is a next integer which is bigger than 3 4 4 5. 57 00:06:26,810 --> 00:06:35,220 Now let's call the function Lord and pass a floating point number. 58 00:06:35,610 --> 00:06:41,190 The flawed method returns the next integer smaller than the given number. 59 00:06:41,310 --> 00:06:51,960 And next let's call the F A B S function which returns the absolute value of a number. 60 00:06:51,960 --> 00:06:59,070 Let's parse this number to the to this function if Fabius and execute and this returns the absolute 61 00:06:59,070 --> 00:07:00,920 value of a number.