0% found this document useful (0 votes)
9 views

Python_Modules_and_Packages_Guide

The document provides a comprehensive overview of Python modules and packages, explaining the distinction between built-in modules and external libraries. It lists several standard library modules, such as os and math, as well as popular third-party libraries like numpy and pandas. Additionally, it covers creating custom modules and managing packages using pip and virtual environments.

Uploaded by

harshit sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Python_Modules_and_Packages_Guide

The document provides a comprehensive overview of Python modules and packages, explaining the distinction between built-in modules and external libraries. It lists several standard library modules, such as os and math, as well as popular third-party libraries like numpy and pandas. Additionally, it covers creating custom modules and managing packages using pip and virtual environments.

Uploaded by

harshit sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Comprehensive List of Python Modules and Packages

1. Introduction to Modules and Packages

Python modules are individual files containing functions and variables.


Packages are directories containing multiple modules, making it easier to organize large projects.

2. Built-in Modules (Standard Library)

These modules are included in Python by default and do not require installation.

- os: Interact with the operating system.


- sys: System-specific parameters and functions.
- math: Mathematical functions like sqrt, sin, cos.
- datetime: Date and time manipulation.
- random: Generate random numbers.
- json: Encode and decode JSON data.
- re: Regular expressions for pattern matching.
- collections: Specialized data structures like deque, defaultdict.
- itertools: Advanced iteration tools.
- functools: Functional programming tools.

3. External Modules (Third-Party Libraries)

These libraries are widely used but must be installed using pip.

- numpy: Numerical computations and arrays.


- pandas: Data analysis and manipulation.
- matplotlib: Data visualization with charts and graphs.
- seaborn: Statistical data visualization.
- requests: HTTP requests handling.
- flask: Lightweight web framework.
- django: Full-stack web framework.
- tensorflow: Machine learning and AI.
- scikit-learn: Data science and ML.
- opencv: Computer vision tasks.

4. Creating and Importing Custom Modules

You can create your own module by saving Python functions in a .py file.

Example:
# mymodule.py
def greet(name):
return f"Hello, {name}!"

Importing:
import mymodule
print(mymodule.greet("Alice"))

5. Package Management with pip and virtual environments

Use pip to install and manage packages:


pip install package_name

Virtual environments help manage dependencies for different projects:


python -m venv myenv
source myenv/bin/activate (Linux/Mac)
myenv\Scripts\activate (Windows)

You might also like