Modules allow organizing Python code into reusable files. The import statement accesses modules, with import module accessing all attributes and from module import function accessing specific functions. Packages are directories containing modules, allowing related modules to be grouped. The __name__ attribute determines if a module is run directly or imported, allowing main blocks to execute code when run directly but not on import.