Lesson 11
Third-Party Modules
Extend Python with pip, PyPI, and libraries like NumPy, Pandas, and Requests.
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
pipinstall packages from PyPI? - How do you use the
requestslibrary 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.
This ecosystem is one of the biggest reasons Python dominates AI and Data Science.
Popular Third-Party Libraries
NumPy
Purpose: Numerical computing — used for large mathematical calculations and arrays.
Pandas
Purpose: Data analysis — ideal for business reports, tables, and datasets.
Matplotlib
Purpose: Visualization — creates graphs, bar charts, line charts, and plots.
SciPy & Scikit-learn
Purpose: Scientific computing & Machine Learning — widely used in AI research and predictive modeling.
Requests
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).
Install a package
Open a terminal and type:
pip install requestsThis 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.
Think of PyPI as the App Store for Python libraries.
Example · Using requests
After installation:
import requests
response = requests.get("https://www.python.org")
print(response.status_code)If the website is reachable, the status code is often:
200What happens internally?
The requests module handles the complex networking code for you.
Checking Installed Packages
You can verify installation using:
pip show requestsTypical information includes:
- Package name
- Version
- Installation location
- Dependencies
Example:
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
pip install requestsStep 2 — Check Website Status
import requests
response = requests.get("https://www.python.org")
if response.status_code == 200:
print("Website is reachable")Expected output:
Website is reachableStep 3 — Verify Installation
pip show requestsKey Points
- Third-party modules extend Python beyond the standard library.
pipinstalls packages from the Python Package Index (PyPI).- Libraries like NumPy, Pandas, and Matplotlib solve specialized problems.
requestsenables HTTP communication with websites and APIs.pip showhelps inspect installed packages.
Interview Questions
- What is the difference between built-in and third-party modules?
- What is
pipused for? - What does PyPI stand for?
- Which library is commonly used for data analysis?
- 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.