3.7. Introduction to Python ModulesΒΆ

One of the best things about the Python programming language is the ecosystem that surrounds it. This chapter introduces you to how to import and use modules that other people have created. You’ll learn about how to use the random module which comes in handy quite frequently in programming. This chapter also does a deeper dive into the Turtles module which isn’t often used to solve real-world problems, but is a useful and fun module to use when learning how to program.


Python provides us the ability to use modules to do everything from sending emails to image processing to complex machine learning. But, even though Python gives us a tremendous amount of power from these modules, you still need to know the python basics in order to glue everything together. We will start by looking at a module used to generate random numbers to learn how to make use of other modules in your programs.

3.7.1. Learning GoalsΒΆ

  • Understand that Python is extensible through modules

  • Understand how to use modules

  • Understand the usefulness of random numbers in programming

  • Learn more about using the turtle module

3.7.2. ObjectivesΒΆ

  • To import an entire module

  • To import a single function from a module

  • To import a module giving it an alias

  • To learn how to use random() and randrange() to get random floats and ints

You have attempted of activities on this page