Author: Saravana Kumar

  • Most Used Python Libraries (with Usage & Why Popular)

    Here’s a helpful guide on the most used Python libraries worldwide, why they are popular, and estimated usage based on developer surveys and real-world application.


    These libraries are used by millions of developers across industries like data science, web development, automation, machine learning, and more.

    ๐Ÿ”ข Percentages are based on data from Stack Overflow Developer Survey, GitHub stars, and industry trends.


    ๐Ÿ“Š 1. NumPy

    • Used for: Numerical computing, arrays, matrix operations
    • Usage: ~65โ€“70%
    • Why Popular: Foundation for data science & machine learning libraries (like pandas, scikit-learn)
    import numpy as np
    a = np.array([1, 2, 3])
    
    

    ๐Ÿงฎ 2. Pandas

    • Used for: Data analysis, data frames, table operations
    • Usage: ~60โ€“65%
    • Why Popular: Makes data handling like Excel but in Python; easy and powerful
    import pandas as pd
    df = pd.DataFrame({"name": ["Alice", "Bob"], "age": [25, 30]})
    
    

    ๐Ÿ“ˆ 3. Matplotlib / Seaborn

    • Used for: Data visualization, charts, graphs
    • Usage: ~55โ€“60%
    • Why Popular: Easy to create line plots, bar charts, and complex visuals
    import matplotlib.pyplot as plt
    plt.plot([1, 2, 3], [4, 5, 6])
    
    

    ๐Ÿค– 4. Scikit-learn

    • Used for: Machine learning (regression, classification, clustering)
    • Usage: ~50โ€“55%
    • Why Popular: Beginner-friendly ML with ready-to-use models
    from sklearn.linear_model import LinearRegression
    
    

    ๐ŸŒ 5. Requests

    • Used for: Web APIs, sending HTTP requests
    • Usage: ~40โ€“50%
    • Why Popular: Extremely simple to make GET/POST requests
    import requests
    r = requests.get("https://api.example.com")
    
    

    ๐Ÿ› ๏ธ 6. Flask

    • Used for: Web development (micro web apps)
    • Usage: ~35โ€“40%
    • Why Popular: Very lightweight and easy to learn for web development
    from flask import Flask
    app = Flask(__name__)
    
    

    ๐Ÿ”’ 7. Django

    • Used for: Full-featured web applications
    • Usage: ~25โ€“30%
    • Why Popular: Built-in admin panel, ORM, user auth โ€” perfect for startups
    django-admin startproject mysite
    
    

    ๐Ÿงช 8. Pytest / Unittest

    • Used for: Testing Python code
    • Usage: ~25โ€“30%
    • Why Popular: Easy to write and manage test cases for automation

    ๐Ÿงน 9. BeautifulSoup

    • Used for: Web scraping
    • Usage: ~20โ€“25%
    • Why Popular: Clean and simple way to parse HTML and extract data

    ๐ŸŽฒ 10. OpenCV

    • Used for: Image processing, computer vision
    • Usage: ~20%
    • Why Popular: Used in AI projects, face detection, camera filters

    ๐Ÿ“ฆ 11. TensorFlow / Keras / PyTorch

    • Used for: Deep learning
    • Usage: ~30โ€“35% among ML developers
    • Why Popular: Used in AI apps, self-driving tech, advanced models

    ๐Ÿ–ผ๏ธ 12. Pillow

    • Used for: Image editing
    • Usage: ~15%
    • Why Popular: Resize, convert, and edit images easily in Python

    ๐Ÿ“‚ 13. os / sys / datetime / json

    • Used for: System operations, file handling, date/time
    • Usage: ~90% (core Python modules)
    • Why Popular: Built-in โ€” no install needed, used in almost every project

    ๐Ÿ“Š Summary Table of Most Popular Python Libraries

    LibraryMain UseUsage %Why Popular
    NumPyMath & arrays70%Fast and powerful base for data tools
    PandasData analysis65%Excel-like + powerful operations
    MatplotlibGraphs and plots60%Easy and flexible visualizations
    Scikit-learnMachine learning55%Great for beginners + fast to use
    RequestsHTTP / API calls50%Easy API use and web requests
    FlaskMicro web apps40%Fast setup for small websites
    DjangoFull web framework30%Rich features, admin panel included
    BeautifulSoupWeb scraping25%Clean HTML parsing
    PytestTesting30%Developer-friendly testing tools
    OpenCVImage processing20%AI, camera, face detection
    TensorFlow/KerasDeep Learning30%Popular in AI and neural networks
    PillowImage editing15%Easy image handling
    os/sys/jsonSystem & utilities90%Core libraries used everywhere

    ๐Ÿง  Final Tip:

    You donโ€™t need to learn all libraries.
    Start with the ones you need for your current project or career path (like web dev, data science, etc.)


  • How to Create Your Own Python Package (Step-by-Step Guide)



    ๐Ÿ”ธ What is a Package?

    • A package is a folder that contains Python files (modules).
    • It helps you organize your code.
    • You can reuse the code in many projects.

    โœ… Why Use Packages?

    • Keeps your code clean and structured
    • Makes code reusable
    • Easy to share with others

    ๐Ÿงณ Step-by-Step: Create Your Own Python Package


    ๐Ÿ”น Step 1: Create Folder Structure

    Letโ€™s say you want a package named mymath.

    mymath/
    โ”‚
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ add.py
    โ””โ”€โ”€ multiply.py
    
    

    โœ… __init__.py makes this folder a package.


    ๐Ÿ”น Step 2: Write Module Files

    ๐Ÿ“„ add.py:

    def add(a, b):
        return a + b
    
    

    ๐Ÿ“„ multiply.py:

    def multiply(a, b):
        return a * b
    
    

    ๐Ÿ“„ __init__.py:

    from .add import add
    from .multiply import multiply
    
    

    ๐Ÿ”น Step 3: Use the Package in Your Code

    Create a new file outside the folder (for example: main.py)

    ๐Ÿ“„ main.py:

    from mymath import add, multiply
    
    print(add(2, 3))        # Output: 5
    print(multiply(2, 3))   # Output: 6
    
    

    โœ… Now your package is working!


    ๐Ÿ”น Step 4 (Optional): Add __all__ in __init__.py

    This helps when you use from mymath import *

    __all__ = ['add', 'multiply']
    
    

    โœ… Practice Time

    Q1: Create a package called greet with:

    • hello.py: hello(name) โ†’ prints โ€œHello, [name]โ€
    • bye.py: bye(name) โ†’ prints โ€œGoodbye, [name]โ€

    Answer:

    Folder:

    greet/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ hello.py
    โ””โ”€โ”€ bye.py
    
    

    ๐Ÿ“„ hello.py:

    def hello(name):
        print(f"Hello, {name}")
    
    

    ๐Ÿ“„ bye.py:

    def bye(name):
        print(f"Goodbye, {name}")
    
    

    ๐Ÿ“„ __init__.py:

    from .hello import hello
    from .bye import bye
    
    

    Use it in main.py:

    from greet import hello, bye
    
    hello("John")
    bye("John")
    
    

    ๐Ÿ“ฆ Bonus: Make it Installable (Advanced)

    To share with others (like on PyPI), create a setup.py:

    from setuptools import setup, find_packages
    
    setup(
        name='mymath',
        version='0.1',
        packages=find_packages()
    )
    
    

    Then run:

    python setup.py install
    
    

    ๐Ÿงพ Summary

    StepWhat to Do
    1Create folder and files
    2Add __init__.py
    3Write code in modules
    4Import and use

    ๐Ÿง  Final Tip:

    You can create your own Python tools using packages.
    Perfect for organizing large projects!


  • Most Used Libraries and Packages in Python | Easy Guide for Beginners



    ๐Ÿ”น 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

    LibraryUse
    NumPyWork with arrays, math functions
    PandasHandle tables (rows and columns)
    MatplotlibDraw charts and graphs
    SeabornMake beautiful statistical graphs

    โœ… Example:

    import numpy as np
    
    a = np.array([1, 2, 3])
    print(a * 2)  # Output: [2 4 6]
    
    

    ๐Ÿค– 2. Machine Learning

    LibraryUse
    scikit-learnBuild ML models like classification
    TensorFlowDeep learning (Google)
    KerasEasy-to-use deep learning library

    โœ… Example:

    from sklearn.linear_model import LinearRegression
    model = LinearRegression()
    
    

    ๐ŸŒ 3. Web Development

    LibraryUse
    FlaskSimple web applications
    DjangoBig web applications (full framework)

    โœ… Flask Example:

    from flask import Flask
    app = Flask(__name__)
    
    @app.route('/')
    def home():
        return "Hello, World!"
    
    

    ๐Ÿงช 4. Testing & Automation

    LibraryUse
    pytestTest your code
    unittestBuilt-in testing tool
    SeleniumAutomate browsers (web testing)

    โœ… Selenium Example:

    from selenium import webdriver
    driver = webdriver.Chrome()
    driver.get("https://google.com")
    
    

    ๐Ÿงฐ 5. Utilities & Tools

    LibraryUse
    osWork with files/folders in system
    datetimeWork with dates and time
    randomGenerate random numbers
    reWork with regular expressions

    โœ… Example:

    import os
    print(os.getcwd())  # Show current folder
    
    

    ๐Ÿ“š 6. Web Scraping

    LibraryUse
    BeautifulSoupGet data from web pages
    requestsSend HTTP requests
    lxmlParse 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

    LibraryUse
    PillowWork with images
    OpenCVImage processing & computer vision

    โœ… Example:

    from PIL import Image
    img = Image.open("image.jpg")
    img.show()
    
    

    ๐Ÿ 8. GUI (Desktop Apps)

    LibraryUse
    TkinterBuilt-in GUI (create windows)
    PyQtPowerful GUI applications

    โœ… Tkinter Example:

    import tkinter as tk
    win = tk.Tk()
    win.title("Hello App")
    win.mainloop()
    
    

    ๐Ÿงพ Summary Table

    CategoryLibraries
    Data & MathNumPy, Pandas, Matplotlib
    Machine Learningscikit-learn, TensorFlow, Keras
    Web DevelopmentFlask, Django
    AutomationSelenium, pytest, unittest
    Web ScrapingBeautifulSoup, requests
    GUI DevelopmentTkinter, PyQt
    Image ProcessingPillow, 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)


  • Difference Between Abstraction and Encapsulation in Python | Simple Words + Examples


    ๐Ÿ”ธ Letโ€™s Understand Both:

    FeatureAbstractionEncapsulation
    MeaningHide how it works, show only what it doesHide data and code in one unit
    FocusOn functionalityOn security and data protection
    Used withAbstract Classes, @abstractmethodPrivate variables, methods, classes
    Real-life ideaTV remote โ€“ You donโ€™t know how it works insideMedicine capsule โ€“ It hides the inner parts

    ๐Ÿ”น Example of Abstraction:

    from abc import ABC, abstractmethod
    
    class Payment(ABC):
        @abstractmethod
        def pay(self):
            pass
    
    class UPI(Payment):
        def pay(self):
            print("Payment using UPI")
    
    p = UPI()
    p.pay()
    
    

    โœ… The user only knows they are using UPI. How it works inside is hidden.


    ๐Ÿ”น Example of Encapsulation:

    class Student:
        def __init__(self):
            self.__marks = 0  # private variable
    
        def set_marks(self, m):
            self.__marks = m
    
        def get_marks(self):
            return self.__marks
    
    s = Student()
    s.set_marks(95)
    print(s.get_marks())  # Output: 95
    
    

    โœ… The marks are protected. We use methods to access them.


    ๐Ÿงพ Summary Table

    Key PointAbstractionEncapsulation
    PurposeHides unnecessary detailsHides sensitive data
    How it’s doneWith abstract classes & methodsUsing private variables & methods
    Access control?NoYes (__private)
    Real-life comparisonTV remoteMedicine capsule

    ๐Ÿง  Easy Tip to Remember

    • ๐Ÿ” Abstraction = “Donโ€™t show how it works” (Focus on What)
    • ๐Ÿ”’ Encapsulation = “Donโ€™t let others touch my data” (Focus on How safe)

    ๐ŸŽฏ Recap in 2 Lines:

    • Abstraction hides logic
    • Encapsulation hides data

    Both help you write clean and secure code.


  • Abstraction in Python | Hiding the Complex, Showing Only the Needed



    ๐Ÿ”น What is Abstraction?

    Abstraction means:

    Hiding the complex details and showing only the important parts.

    It helps us to:

    • Focus on what an object does
    • Not worry about how it does it

    ๐Ÿ”ธ Real-Life Example:

    Think about a TV remote:

    • You press the power button to turn on the TV.
    • You donโ€™t need to know how electricity flows inside.

    ๐ŸŸข This is abstraction โ€” showing only the button (interface), hiding the working inside.


    ๐Ÿ”น Abstraction in Python

    We use:

    • Abstract Base Class (ABC)
    • The abc module

    ๐Ÿ”น How to Use Abstraction in Python

    1. Import ABC and abstractmethod
    2. Create a class that inherits from ABC
    3. Use @abstractmethod to define abstract methods
    4. Subclass must override these methods

    ๐Ÿ”น Example:

    from abc import ABC, abstractmethod
    
    class Animal(ABC):  # Abstract class
        @abstractmethod
        def sound(self):  # Abstract method
            pass
    
    class Dog(Animal):
        def sound(self):
            print("Dog barks")
    
    class Cat(Animal):
        def sound(self):
            print("Cat meows")
    
    d = Dog()
    c = Cat()
    d.sound()
    c.sound()
    
    

    ๐ŸŸข Output:

    Dog barks
    Cat meows
    
    

    ๐Ÿ”น Key Rules of Abstraction:

    • You cannot create an object of abstract class.
    • Child class must implement (override) abstract methods.
    • Abstract class can also have normal methods.

    ๐Ÿ”น Abstract Class with Normal Method

    from abc import ABC, abstractmethod
    
    class Vehicle(ABC):
        @abstractmethod
        def start(self):
            pass
    
        def fuel_type(self):
            print("Fuel type is petrol")
    
    class Car(Vehicle):
        def start(self):
            print("Car is starting...")
    
    c = Car()
    c.start()
    c.fuel_type()
    
    

    ๐Ÿ“ Practice Questions with Answers

    โ“ Q1: Create an abstract class Shape with abstract method area(). Implement it in Rectangle and Circle.

    โœ… Answer:

    from abc import ABC, abstractmethod
    
    class Shape(ABC):
        @abstractmethod
        def area(self):
            pass
    
    class Rectangle(Shape):
        def area(self):
            print("Area = length ร— width")
    
    class Circle(Shape):
        def area(self):
            print("Area = ฯ€ ร— radiusยฒ")
    
    r = Rectangle()
    c = Circle()
    r.area()
    c.area()
    
    

    โ“ Q2: Make an abstract class Device with turn_on() and turn_off() methods.

    โœ… Answer:

    from abc import ABC, abstractmethod
    
    class Device(ABC):
        @abstractmethod
        def turn_on(self):
            pass
    
        @abstractmethod
        def turn_off(self):
            pass
    
    class Laptop(Device):
        def turn_on(self):
            print("Laptop is turning on")
    
        def turn_off(self):
            print("Laptop is shutting down")
    
    l = Laptop()
    l.turn_on()
    l.turn_off()
    
    

    ๐Ÿงพ Summary Table

    TermMeaning
    AbstractionHiding how things work, showing only whatโ€™s needed
    Abstract ClassA class with abstract methods
    Abstract MethodMethod with no body (empty function)
    @abstractmethodUsed to create abstract methods

    ๐ŸŽฏ Quick Recap

    • Abstraction = Hiding details, showing only the essentials.
    • Use abc module, ABC, and @abstractmethod.
    • Helps write clean, structured, and safe code.

    ๐Ÿ“ฃ Coming Up Next:

    โžก๏ธ Difference Between Abstraction and Encapsulation in Python (Simple Words)