Python 3D Academyবাংলা

Modules & Packages in Python

Chapter 19: Modules & Packages

4 short lessons, with 3D animations, quizzes and coding tasks.

The lessons

  1. Importing modules

    A module is a file of ready-made code; import math puts the name math on your desk, and you reach its tools with a dot, math.sqrt(16).

  2. Handy modules: random, collections, datetime

    random picks by chance, collections.Counter counts things in one line, and datetime.date does calendar maths.

  3. Your own modules

    Any .py file is a module: put your helpers in helpers.py, and a program next to it can import helpers and use them.

  4. Packages, and installing more with pip

    A package is a folder of modules (with an init.py file), reached with dots like from shapes.square import area, and pip installs packages other people have published.