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
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Python Functions, Mo | Master Data Science with Python lesso | BraveProgrammer
  1. Courses
  2. /
  3. Master Data Science with Python

Lesson 4 of 60

·python

Python Functions, Modules, and Packages

20 minutes

Course progress7%

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.
Make it stickPractice what you've learned1 quiz · 4 practical tests · Optional activities from Master Data Science with PythonBrowse activities
Previous lessonPython Refresher: Variables, Data Types, and Control FlowContinue to lesson 5Version Control with Git & GitHubBack to Master Data Science with Python curriculum