πΉ What is a Python Library or Package?
- A library is a group of ready-made code that helps you do tasks easily.
- A package is a folder that contains many libraries or modules.
β You donβt need to write everything from scratch. Just import and use!
πΈ How to Install a Library?
pip install library_name
Example:
pip install numpy
πΉ Most Popular Python Libraries by Category
π 1. Data Analysis & Math
Library | Use |
---|---|
NumPy | Work with arrays, math functions |
Pandas | Handle tables (rows and columns) |
Matplotlib | Draw charts and graphs |
Seaborn | Make beautiful statistical graphs |
β Example:
import numpy as np
a = np.array([1, 2, 3])
print(a * 2) # Output: [2 4 6]
π€ 2. Machine Learning
Library | Use |
---|---|
scikit-learn | Build ML models like classification |
TensorFlow | Deep learning (Google) |
Keras | Easy-to-use deep learning library |
β Example:
from sklearn.linear_model import LinearRegression
model = LinearRegression()
π 3. Web Development
Library | Use |
---|---|
Flask | Simple web applications |
Django | Big web applications (full framework) |
β Flask Example:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return "Hello, World!"
π§ͺ 4. Testing & Automation
Library | Use |
---|---|
pytest | Test your code |
unittest | Built-in testing tool |
Selenium | Automate browsers (web testing) |
β Selenium Example:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://google.com")
π§° 5. Utilities & Tools
Library | Use |
---|---|
os | Work with files/folders in system |
datetime | Work with dates and time |
random | Generate random numbers |
re | Work with regular expressions |
β Example:
import os
print(os.getcwd()) # Show current folder
π 6. Web Scraping
Library | Use |
---|---|
BeautifulSoup | Get data from web pages |
requests | Send HTTP requests |
lxml | Parse HTML and XML data |
β Example:
import requests
from bs4 import BeautifulSoup
r = requests.get("https://example.com")
soup = BeautifulSoup(r.text, 'html.parser')
print(soup.title.text)
πΌοΈ 7. Image and Media
Library | Use |
---|---|
Pillow | Work with images |
OpenCV | Image processing & computer vision |
β Example:
from PIL import Image
img = Image.open("image.jpg")
img.show()
π 8. GUI (Desktop Apps)
Library | Use |
---|---|
Tkinter | Built-in GUI (create windows) |
PyQt | Powerful GUI applications |
β Tkinter Example:
import tkinter as tk
win = tk.Tk()
win.title("Hello App")
win.mainloop()
π§Ύ Summary Table
Category | Libraries |
---|---|
Data & Math | NumPy, Pandas, Matplotlib |
Machine Learning | scikit-learn, TensorFlow, Keras |
Web Development | Flask, Django |
Automation | Selenium, pytest, unittest |
Web Scraping | BeautifulSoup, requests |
GUI Development | Tkinter, PyQt |
Image Processing | Pillow, OpenCV |
π§ Final Tip:
Learn the library you need for your project.
You donβt have to learn all at once.
π£ Coming Up Next:
β‘οΈ How to Create Your Own Python Package (Step-by-Step)
Leave a Reply