From the course: Learning Python

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Importing and using modules

Importing and using modules - Python Tutorial

From the course: Learning Python

Importing and using modules

- [Instructor] One of the most powerful features of the Python ecosystem is the large number of library modules of pre-built code that you can use in your programs. The standard Python installation contains quite a few of these modules, and some of which we're going to learn more about later in the course, but, before we get there, let's take a look at a simple example that shows how to take advantage of all this code that you don't have to write yourself. So let's open up the modules_start file, and what I'm going to do is tell Python that my program wants to use the math module, which contains a whole bunch of functions for performing all kinds of mathematical calculations. To do that, all I need to do is use the import statement along with the name of the module that I want to use. So I'm going to write import math. Now, let's suppose I wanted to calculate the square root of a number. To do that, I can take advantage of…

Contents