- [Instructor] As we've discussed,
there are quite a number of libraries
available to you as part of
the Python standard library.
In this video, I just wanna take a brief look
at the math module within the Python standard library
which contains many common mathematical functions.
In order to use those functions,
you will need to import the math library.
You may recall that I've demonstrated
some tab completion capabilities,
so if you want to see what's in the math library,
you can now type math dot and hit Tab,
and now you can see all of these different functions
and a couple of variables;
e, pi, nan, tau.
Each of these are technically constants
that you can use in your code,
but in Python, we don't actually have
true constant data,
which means you could accidentally modify
the variables that are pre-defined
in the math module
if you assign a new value to them.
So you do wanna be careful
not to accidentally overwrite those variables
once you import them into your code.
As you can see here, there's a whole bunch
of functions available for your use.
Let's say you don't know
how to use a particular function
and you wanna learn more about it.
You can type the name of the function
and a question mark, and once again,
it will give you some documentation
about that particular function.
For instance, if I wanna go ahead
and calculate the square root of a value,
let's say we wanna do the square root of 900,
you can see quickly that the square root of 900 is 30.
Similarly, let's say we wanted to calculate
the absolute value of a negative number.
We could use FABS,
which is floating point absolute value,
and you can see that it gives you back
the positive result of calling that function.
Again, if you have any use
for basic mathematical functionality,
you'll definitely want to take a look
at the math library.
Similarly, in the online documentation
that I've shown you a couple of times now
at python.org, you will definitely want to go back
once again and take a look at that master list
of all the different modules that are built-in
to the Python standard library for you
so that you can get a sense of the categories
of functionality that are available.
Eventually, you'll probably want to dive into
a number of those libraries
to see what pre-existing capabilities they give you.
In Python, they take
the everything but the kitchen sink approach
where they include as much as possible
so that you can focus on the logic
of what you need to get done
as opposed to the low-level details
of how to perform everyday tasks
that lots of Python programmers have performed
in the past.
That's just with the Python standard library.
That doesn't include the thousands of other libraries
that are available to you,
most of which are open source.
You can access many of them on sites like github.com.