Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Python Fundamentals

Lesson 21 of 55 · Python

Modules and Packages

Duration: 20 minutes

Modules and Packages\n\nA module is a single .py file that can be imported. A package is a directory containing an __init__.py file, allowing you to group related modules together.\n\n```python\n# my_module.py\ndef hello(name):\n return f'Hello, {name}!'

\n# In another script\nimport my_module\nprint(my_module.hello('Bob'))\n```\n\nOrganizing code into modules and packages makes large projects easier to maintain and reuse.\n

Previous: Exception HandlingNext: Importing Standard Library