Hello welcome to this tutorial on the mad module when writing Python programs.
We might have to perform mathematical operations frequently.
Say for example calculating the square root of a number are finding the factorial of a number etc..
Python provides the standard library that simplifies the programming process and removes the need to
read write commonly used functions are operations.
The python standard library is a collection of modules accessible from other programs.
The libraries are modules provide us with useful data types functions and tools.
So if we make of a program's use the existing library module the development process will be much more
comfortable and great and the python library is part of a very standard Python installation.
And if you want to use these library modules you need to call them or import them into your python programs.
You need to have what is known as an import statement in your program in order to access the functions
or are other tools or data types defined in these modules.
In this tutorial we're going to discuss about the map module and we will see how to access the functions
defined in this module.
The math module provides a lot of useful functions that we will now see in order to access these functions
and the tools.
Defying any math module we need to import this module and this is this statement the import statement
that we need to put in our python program in order to access these functions in this module.
Now say for example you want to access a method name Eskew Artie.
This is the method name is Q. Artie and this method our function is used to get the square root of a
number.
And this function is defined in the math module.
Now in order to access this function in your program you need to use the dot operator so mad dot function
name and you specify the number here.
So for example a you pass it as an argument see the dot notation is a way we connect the name of the
object in a our case it is the math module to the name of the method.
It can perform the math module has by as a constant.
That can be used in mathematical calculations such as calculating the area of a circle.
Now in order to access this the constant pi from our python programs you can use the dot notation here
as well.
So you're going to access this constant by using the dot notation like this so we will now see how we
can access the functions from our Jupiter notebook or the python programs so in order to access the
math module we need to first import this module into our programs.
For this we use the import statement.
We are going to have a detailed discussion on import statements in the coming up sessions.
So for now in order to access any of these standard libraries the python standard libraries you can
use the import statement like this and then execute this line in order to see the contents of the library
module man.
We can use the help function to let us pass the math module to the help function.
So here you see the list of the different functions and tools that are available in this module.
Now let's access some of these functions from our python program Firstly let us access the constant
pi from our program using the dot notation.
So here is the value of the content by next.
Let's call the function square root as you are d default name and let's pass an argument to this function.
Sixteen so here.
This function in the math module has calculated the square root of the number and return the result.
We can also calculate the factorial of a number using the function factorial defined in the math module.
So let's pass the argument 5 to this function and then execute this line.
And this function has returned the value 120 it is the factorial of the integer value 5.
Now let's call two functions that are related to rounding the same function and the flawed function.
They still function returns the next integer bigger than the given number.
So in other words the method sealed returns the smallest integer bigger than the given number.
So let's execute this line and see the result.
So it has returned the next integer bigger than this number minus 2.
Next we will pass a positive another floating point about the dot 0 5 to this function C though the
value return now is 4 because 4 is a next integer which is bigger than 3 4 4 5.
Now let's call the function Lord and pass a floating point number.
The flawed method returns the next integer smaller than the given number.
And next let's call the F A B S function which returns the absolute value of a number.
Let's parse this number to the to this function if Fabius and execute and this returns the absolute
value of a number.