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. Master Data Science with Python

Lesson 4 of 60 · python

Python Functions, Modules, and Packages

Duration: 20 minutes

Functions, Modules, and Packages

Modular code makes data pipelines reusable and testable.

Defining functions

def greet(name: str) -> str:
    """Return a friendly greeting."""
    return f"Hello, {name}!"

Importing standard modules

import math
from collections import Counter

print(math.sqrt(16))   # 4.0

Installing third‑party packages

pip install numpy pandas

Creating your own package

my_project/
│
├── my_package/
│   ├── __init__.py
│   └── utils.py
└── setup.py

utils.py could contain helper functions used across notebooks.

Info

Use import this to see the Zen of Python.

Previous: Python Refresher: Variables, Data Types, and Control FlowNext: Version Control with Git & GitHub