image

10USEFUL PYTHON MODULES

As you learned in Chapter 7, a Python module is any combination of functions, classes, and variables. Python uses modules to group functions and classes in order to make them easier to use. For example, the turtle module, which we used in previous chapters, groups functions and classes that are used to create a canvas for a turtle to draw on the screen.

When you import a module into a program, you can use all of its contents. For example, when we imported the turtle module in Chapter 4, we had access to the Pen class, which we used to create an object representing the turtle’s canvas:

>>> import turtle>>> t = turtle.Pen() ...

Get Python for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.