Skip to main content
MahiDev — Learn. Build. Become AI-ready.

Lesson 11

Third-Party Modules

Extend Python with pip, PyPI, and libraries like NumPy, Pandas, and Requests.

Beginner10 min

What you will learn

By the end of this lesson, you'll understand:

  • Why are Python's built-in modules not enough for every project?
  • What do third-party modules provide?
  • How does pip install packages from PyPI?
  • How do you use the requests library to communicate with a website?

What are Third-Party Modules?

Python already includes many built-in modules like math, os, and random.

But real-world applications often need specialized capabilities such as:

  • Machine Learning
  • Data Analysis
  • Web Development
  • Image Processing
  • Automation Testing

These are provided by third-party modules.

Built-in vs Third-Party

Built-in Modules Third-Party Modules
Already included with Python Installed separately using pip
Examples: math, os, sys Examples: NumPy, Pandas, Requests

Key idea: Built-in modules come with Python; third-party modules extend Python's capabilities.

Why Do We Need Third-Party Modules?

Instead of writing thousands of lines of code yourself, you install libraries that already solve complex problems.

Python project using NumPy, Pandas, Requests, Matplotlib

This ecosystem is one of the biggest reasons Python dominates AI and Data Science.

NumPy

NumPy for numerical computingNumPy for numerical computing

Purpose: Numerical computing — used for large mathematical calculations and arrays.

Pandas

Pandas for data analysisPandas for data analysis

Purpose: Data analysis — ideal for business reports, tables, and datasets.

Matplotlib

Matplotlib for visualizationMatplotlib for visualization

Purpose: Visualization — creates graphs, bar charts, line charts, and plots.

SciPy & Scikit-learn

SciPy and Scikit-learn for scientific computing and MLSciPy and Scikit-learn for scientific computing and ML

Purpose: Scientific computing & Machine Learning — widely used in AI research and predictive modeling.

Requests

Requests for web and API communicationRequests for web and API communication

Purpose: Web communication — allows Python programs to communicate with websites and APIs.

What is pip?

pip is Python's package manager.

It downloads packages from the Python Package Index (PyPI).

pip downloads from PyPI into your project

Install a package

Open a terminal and type:

bash
pip install requests

This downloads and installs the requests library.

What is PyPI?

PyPI stands for Python Package Index.

It is the official repository containing thousands of Python packages.

Publishing packages on PyPIPublishing packages on PyPI
Evaluating Python package qualityEvaluating Python package quality
Python packaging and distributionPython packaging and distribution

Think of PyPI as the App Store for Python libraries.

Example · Using requests

After installation:

python
import requests

response = requests.get("https://www.python.org")

print(response.status_code)

If the website is reachable, the status code is often:

text
200

What happens internally?

Python uses requests to reach python.org

The requests module handles the complex networking code for you.

Checking Installed Packages

You can verify installation using:

bash
pip show requests

Typical information includes:

  • Package name
  • Version
  • Installation location
  • Dependencies

Example:

text
Name: requests
Version: 2.x.x
Location: /usr/local/lib/...

Where Third-Party Modules Are Used

Domain Popular Libraries
Data Science NumPy, Pandas
Visualization Matplotlib
Machine Learning Scikit-learn, Keras
Scientific Computing SciPy
Web APIs Requests
NLP Natural language packages

According to your source, these libraries make Python suitable for:

  • Web Development
  • Machine Learning
  • Data Analysis
  • Image Processing
  • Automation
  • Testing

Practice Exercise

Step 1 — Install Requests

bash
pip install requests

Step 2 — Check Website Status

python
import requests

response = requests.get("https://www.python.org")

if response.status_code == 200:
    print("Website is reachable")

Expected output:

text
Website is reachable

Step 3 — Verify Installation

bash
pip show requests

Key Points

  • Third-party modules extend Python beyond the standard library.
  • pip installs packages from the Python Package Index (PyPI).
  • Libraries like NumPy, Pandas, and Matplotlib solve specialized problems.
  • requests enables HTTP communication with websites and APIs.
  • pip show helps inspect installed packages.

Interview Questions

  1. What is the difference between built-in and third-party modules?
  2. What is pip used for?
  3. What does PyPI stand for?
  4. Which library is commonly used for data analysis?
  5. What does HTTP status code 200 usually indicate?

Summary

Tool Purpose
pip Install Python packages
PyPI Official package repository
NumPy Numerical computing
Pandas Data analysis
Matplotlib Visualization
Requests HTTP & web communication
Scikit-learn Machine Learning

Python's greatest strength is its ecosystem. Instead of building everything yourself, you install well-tested libraries that provide powerful capabilities with only a few lines of code.

Next

Next lesson: Functional & Object-Oriented Programming — how Python supports both programming paradigms and when to use functions versus classes.