Monday, April 13, 2026

Creating a Vegetarian & Non-Vegetarian Food Wheel of the World in Python

 


 Creating a Vegetarian & Non-Vegetarian Food Wheel of the World in Python

Food connects cultures, traditions, and people across the globe. What if you could explore world cuisines in a fun, interactive way using Python? That’s where a Food Wheel App comes in—a spinning wheel that randomly selects vegetarian or non-vegetarian dishes from different countries.

In this blog, you’ll learn how to build a simple and interactive food selection wheel using Python. This project is perfect for beginners and a great way to combine programming with creativity.

Project Idea: What is a Food Wheel?

A food wheel is a visual spinner that randomly selects an item from a list. In this case, we will:

  • Create two categories:  Vegetarian and  Non-Vegetarian
  • Add dishes from different countries
  • Spin the wheel to randomly pick a dish

 This can be used for:

  • Deciding what to eat
  • Learning global cuisines
  • Fun classroom or family activities

 Tools You Will Need

  • Python installed
  • Basic knowledge of lists and functions
  • random module
  • Optional: tkinter or matplotlib for visualization

 Step 1: Create Food Lists

Let’s start by defining vegetarian and non-vegetarian dishes.

import random

veg_foods = [
    "Paneer Butter Masala (India)",
    "Margherita Pizza (Italy)",
    "Falafel (Middle East)",
    "Veg Sushi (Japan)",
    "Ratatouille (France)",
    "Veg Burger (USA)"
]

nonveg_foods = [
    "Chicken Biryani (India)",
    "Sushi (Japan)",
    "Beef Steak (USA)",
    "Grilled Chicken (Brazil)",
    "Fish & Chips (UK)",
    "Lamb Kebab (Turkey)"
]

 Step 2: Create a Food Selector Function

def choose_food(category):
    if category == "veg":
        return random.choice(veg_foods)
    elif category == "nonveg":
        return random.choice(nonveg_foods)
    else:
        return "Invalid choice"

 Step 3: Simulate a Wheel Spin

def spin_wheel():
    category = random.choice(["veg", "nonveg"])
    food = choose_food(category)
    print(f" Category: {category.upper()}")
    print(f" You should try: {food}")

 Step 4: Run the Program

spin_wheel()

 Every time you run this, you’ll get a new dish suggestion!

 Step 5: Create a Visual Wheel (Optional)

For a more interactive experience, you can use matplotlib to create a simple wheel.

import matplotlib.pyplot as plt

foods = veg_foods + nonveg_foods

plt.pie([1]*len(foods), labels=foods)
plt.title("Food Wheel of the World")
plt.show()

 This creates a pie chart that acts like a food wheel.

 Bonus: Add User Input

Let users choose their preference.

choice = input("Enter veg or nonveg: ")
print("🍽️ Your dish:", choose_food(choice))

Advanced Ideas

Take your project to the next level:

  •  Build a GUI using tkinter
  •  Add more countries and dishes
  •  Add sound effects for spinning
  •  Convert into a mobile or web app
  •  Integrate AI to suggest meals based on mood

 Educational Benefits

This project helps you learn:

  • Python basics (lists, functions, randomness)
  • GUI development concepts
  • Data organization
  • Creative problem-solving

 Real-Life Applications

  • Meal planning apps
  • Restaurant recommendation systems
  • Educational tools for geography and culture
  • Fun decision-making apps

 Final Thoughts

Building a Vegetarian and Non-Vegetarian Food Wheel in Python is a fun and engaging project that blends coding with real-world creativity. It shows how simple programming concepts can be used to create interactive and useful applications.

Whether you’re a beginner or an aspiring developer, projects like this make learning Python enjoyable and practical.

12 Smart NotebookLM Setups for Education: Learn Faster, Teach Better

 


 12 Smart NotebookLM Setups for Education: Learn Faster, Teach Better

AI tools are reshaping education, and one of the most powerful among them is NotebookLM. Designed to help users understand and organize information, NotebookLM allows students and teachers to turn notes, documents, and sources into structured knowledge.

But using it effectively requires the right setup. In this guide, we’ll explore 12 smart NotebookLM setups that can dramatically improve learning, revision, and teaching.

 1. Subject-Wise Study Hub

Create separate notebooks for each subject like Physics, Math, or History.

 How It Helps

  • Keeps notes organized
  • Avoids confusion between topics
  • Makes revision faster

Treat each notebook as a mini knowledge base.

 2. Exam Preparation Notebook

Upload textbooks, class notes, and previous question papers into one notebook.

Use It For

  • Quick summaries
  • Important questions
  • Revision guides

 Ask NotebookLM to generate exam-focused summaries.

 3. Concept Simplifier Setup

Add complex topics and let AI break them into simple explanations.

 Example

  • “Explain quantum physics in simple terms”
  • “Simplify calculus concepts”

 Perfect for beginners struggling with difficult subjects.

 4. Smart Notes Generator

Upload lectures, PDFs, or handwritten notes.

 What It Does

  • Converts raw content into structured notes
  • Highlights key points
  • Creates bullet summaries

 Saves hours of manual note-making.

 5. Question & Answer Practice Setup

Turn your notes into a Q&A system.

 How

  • Ask NotebookLM to generate questions
  • Practice answering them
  • Use it like a self-test tool

Great for active learning.

 6. Assignment & Research Assistant

Use NotebookLM to gather and organize research materials.

Benefits

  • Extracts key insights from sources
  • Helps structure assignments
  • Reduces research time

Ideal for essays and projects.

 7. Book Summary Notebook

Upload entire books or chapters.

 What You Get

  • Chapter summaries
  • Key themes
  • Important quotes

 Makes reading more efficient.

 8. Multi-Source Comparison Setup

Add multiple sources on the same topic.

 Use Case

  • Compare different viewpoints
  • Identify similarities and differences

 Useful for critical thinking and analysis.

 9. Lecture Companion Setup

Upload lecture transcripts or notes.

 Features

  • Real-time clarification
  • Instant summaries
  • Doubt solving

 Acts like a personal tutor during lectures.

 10. Language Learning Notebook

Use NotebookLM to learn new languages.

 How It Helps

  • Translate content
  • Explain grammar rules
  • Practice sentence formation

Makes language learning interactive.

 11. Revision Booster Setup

Before exams, use NotebookLM for quick revision.

 What It Can Do

  • Generate flashcards
  • Create short summaries
  • Highlight important topics

 Perfect for last-minute preparation.

12. Teacher’s Content Creator

Teachers can use NotebookLM to create teaching materials.

 Use Cases

  • Lesson plans
  • Quiz questions
  • Study guides

 Saves time and improves teaching quality.

 Why These Setups Matter

Using NotebookLM strategically helps you:

  • Learn faster
  • Stay organized
  • Improve understanding
  • Reduce study time

It transforms passive reading into active learning.

 Tips for Best Results

  • Upload high-quality, relevant sources
  • Ask clear and specific questions
  • Cross-check important information
  • Use it as a support tool, not a replacement for thinking

 Final Thoughts

NotebookLM is more than just a note-taking tool—it’s a powerful learning assistant. With the right setups, students can study smarter, and teachers can teach more effectively.

As AI continues to evolve, tools like NotebookLM will play a key role in shaping the future of education. The goal is not just to learn more, but to learn better.

Sunday, April 12, 2026

Python List Slicing: A Complete Guide for Beginners

 


 Python List Slicing: A Complete Guide for Beginners

Python is known for its simplicity and powerful features, and one of the most useful among them is list slicing. It allows you to extract parts of a list quickly and efficiently without writing complex loops.

In this guide, you’ll learn everything about Python list slicing—from basic syntax to advanced tricks—with easy examples.

 What is List Slicing?

List slicing is a way to access a portion (subset) of a list using a special syntax.

Instead of accessing one element at a time, slicing lets you grab multiple elements in a single line of code.

 Basic Syntax of List Slicing

list[start:stop:step]

 Understanding the Parameters

  • start → Index where slicing begins (inclusive)
  • stop → Index where slicing ends (exclusive)
  • step → Interval between elements

 Example List

numbers = [10, 20, 30, 40, 50, 60]

 1. Basic Slicing

print(numbers[1:4])

Output:

[20, 30, 40]

 Starts from index 1 and stops before index 4.

 2. Omitting Start or Stop

From Beginning

print(numbers[:3])

Output:

[10, 20, 30]

Till End

print(numbers[2:])

Output:

[30, 40, 50, 60]

 3. Using Step

print(numbers[0:6:2])

Output:

[10, 30, 50]

 Skips every second element.

 4. Negative Indexing

Negative indices start from the end of the list.

print(numbers[-4:-1])

Output:

[30, 40, 50]

 5. Reverse a List

print(numbers[::-1])

Output:

[60, 50, 40, 30, 20, 10]

Very useful shortcut to reverse lists.

 6. Copying a List

copy_list = numbers[:]

 Creates a shallow copy of the list.

7. Partial Step Slicing

print(numbers[::3])

Output:

[10, 40]

 8. Slicing Strings (Bonus)

List slicing also works on strings!

text = "Python"
print(text[1:4])

Output:

yth

 Common Mistakes to Avoid

❌ Forgetting that stop index is excluded
❌ Using out-of-range indices incorrectly
❌ Confusing negative indexing

 Real-Life Use Cases

  • Extracting data subsets
  • Reversing lists quickly
  • Sampling data
  • Working with strings and text
  • Data analysis and preprocessing

 Pro Tips

  • Use slicing instead of loops for cleaner code
  • Combine slicing with functions for powerful operations
  • Practice with different ranges to master it

 Final Thoughts

Python list slicing is a simple yet powerful feature that can make your code shorter, cleaner, and more efficient. Once you understand how start, stop, and step work together, you can manipulate lists like a pro.

Whether you’re a beginner or an experienced programmer, mastering slicing will significantly improve your Python skills.

10 Websites to Make Money from Home: A Complete Guide for Beginners

 


 10 Websites to Make Money from Home: A Complete Guide for Beginners

The internet has opened countless opportunities to earn money without leaving your home. Whether you’re a student, homemaker, or professional looking for extra income, there are trusted platforms that allow you to work remotely and get paid.

In this blog, we’ll explore 10 reliable websites where you can start earning from home, along with how they work and who they’re best suited for.

 1. Upwork

Upwork is one of the largest freelancing platforms in the world.

 What You Can Do

  • Writing
  • Graphic design
  • Programming
  • Digital marketing

 Why Use It

  • Global clients
  • Secure payments
  • Long-term projects

 Best for freelancers with skills.

 2. Fiverr

Fiverr allows you to sell services starting from $5.

 Popular Gigs

  • Logo design
  • Video editing
  • Content writing
  • Voice-over

 Great for beginners starting freelancing.

 3. Freelancer

Freelancer connects you with clients through bidding.

 Features

  • Wide range of jobs
  • Competitive bidding system
  • Skill-based projects

 Ideal for people who can compete on pricing and skills.

 4. Chegg

Chegg allows you to earn by helping students.

 How You Earn

  • Answer academic questions
  • Online tutoring

Perfect for students and subject experts.

 5. Amazon (Work from Home Options)

Amazon offers remote jobs and earning options.

 Opportunities

  • Customer support
  • Affiliate marketing
  • Selling products

 Good for both part-time and full-time income.

 6. YouTube

YouTube lets you earn by creating videos.

 Income Sources

  • Ads revenue
  • Sponsorships
  • Affiliate links

 Best for creative individuals.

 7. Shutterstock

Sell your photos, videos, and designs online.

 What You Need

  • Camera or smartphone
  • Creative content

 Great for photographers and designers.

 8. Swagbucks

Earn money by completing simple tasks.

Tasks Include

  • Surveys
  • Watching videos
  • Shopping online

 Easy option for beginners.

 9. Rev

Rev pays you for transcription and captioning work.

 Requirements

  • Good listening skills
  • Basic English knowledge

Ideal for people who prefer simple tasks.

10. Etsy

Sell handmade or digital products.

 What You Can Sell

  • Crafts
  • Printables
  • Art

 Perfect for creative entrepreneurs.

 Tips to Start Earning Online

  • Choose a platform based on your skills
  • Build a strong profile or portfolio
  • Be consistent and patient
  • Avoid scams—use trusted websites only
  • Upgrade your skills regularly

 Things to Keep in Mind

  • Earnings take time to grow
  • Competition can be high
  • Some platforms charge fees
  • Consistency is key

 Final Thoughts

Making money from home is more accessible than ever. With the right platform and dedication, you can build a steady income stream online. Whether you choose freelancing, content creation, or simple tasks, the opportunities are endless.

Start small, stay consistent, and gradually scale your efforts. Your online earning journey begins with a single step.

Generate Wi-Fi QR Code Instantly with Python: A Complete Guide

 

Generate Wi-Fi QR Code Instantly with Python: A Complete Guide

Sharing Wi-Fi passwords can be frustrating—especially when they are long, complex, or frequently updated. Instead of typing passwords again and again, you can generate a QR code that allows users to connect instantly by simply scanning it. With Python, creating a Wi-Fi QR code is quick, efficient, and customizable.

In this blog, you’ll learn how to generate Wi-Fi QR codes using Python, understand the format behind them, and explore practical use cases.

1. What is a Wi-Fi QR Code?

A Wi-Fi QR code contains your network credentials in a special format. When scanned, it automatically connects a device to the Wi-Fi network without manually entering the password.

Standard Format:

WIFI:T:<encryption>;S:<SSID>;P:<password>;H:<hidden>;;

Where:

  • T → Encryption type (WPA, WEP, or nopass)
  • S → Network name (SSID)
  • P → Password
  • H → Hidden network (true/false)

2. Why Use Wi-Fi QR Codes?

  • Faster connection for guests
  • No need to share passwords verbally
  • Reduces typing errors
  • Useful for cafes, offices, and homes
  • Enhances user experience

3. Required Python Library

We’ll use the qrcode library to generate QR codes.

Installation

pip install qrcode[pil]

4. Generate a Basic Wi-Fi QR Code

Here’s a simple Python script:

import qrcode

ssid = "MyWiFi"
password = "12345678"
encryption = "WPA"  # WPA, WEP, or nopass

wifi_data = f"WIFI:T:{encryption};
S:{ssid};P:{password};H:false;;" qr = qrcode.make(wifi_data) qr.save("wifi_qr.png") print("QR Code generated successfully!")

5. Customize the QR Code

You can create more visually appealing QR codes:

import qrcode

qr = qrcode.QRCode(
    version=1,
    box_size=10,
    border=4
)

wifi_data = "WIFI:T:WPA;S:MyWiFi;
P:12345678;H:false;;" qr.add_data(wifi_data) qr.make(fit=True) img = qr.make_image(fill="black",
back_color="white") img.save("custom_wifi_qr.png")

6. Add Logo to QR Code (Advanced)

You can embed a logo in the center:

from PIL import Image
import qrcode

qr = qrcode.QRCode(error_correction=
qrcode.constants.ERROR_CORRECT_H) qr.add_data("WIFI:T:WPA;S:MyWiFi;
P:12345678;H:false;;") qr.make() img = qr.make_image().convert("RGB") logo = Image.open("logo.png") logo = logo.resize((60, 60)) pos = ((img.size[0] - logo.size[0]) // 2, (img.size[1] - logo.size[1]) // 2) img.paste(logo, pos) img.save("wifi_qr_logo.png")

7. Batch Generate Multiple Wi-Fi QR Codes

Useful for businesses managing multiple networks:

networks = [
    ("OfficeWiFi", "pass123"),
    ("GuestWiFi", "guest456")
]

import qrcode

for ssid, password in networks:
    data = f"WIFI:T:WPA;S:{ssid};
P:{password};H:false;;" img = qrcode.make(data) img.save(f"{ssid}_qr.png")

8. Real-World Use Cases

1. Cafes and Restaurants

Display QR codes for customers to connect instantly.

2. Offices

Provide easy Wi-Fi access to employees and visitors.

3. Homes

Share Wi-Fi with guests without revealing passwords.

4. Events

Offer seamless internet access at conferences or gatherings.

9. Tips for Better QR Codes

  • Use high contrast colors (black & white works best)
  • Keep QR code size large enough for scanning
  • Avoid overcrowding with large logos
  • Test the QR code before sharing

10. Common Issues and Fixes

QR Code Not Working

  • Check SSID and password accuracy
  • Ensure correct encryption type

Not Scanning Properly

  • Increase image resolution
  • Improve lighting conditions

Connection Fails

  • Ensure Wi-Fi is active
  • Verify device compatibility

11. Security Considerations

  • Avoid sharing sensitive networks publicly
  • Change passwords regularly
  • Use guest networks for public access
  • Limit access if needed

Conclusion

Generating a Wi-Fi QR code with Python is a simple yet powerful way to improve user experience and streamline connectivity. With just a few lines of code, you can create QR codes that eliminate the hassle of manually entering passwords.

From basic generation to advanced customization with logos and batch processing, Python gives you complete control over how you share network access. Whether you’re managing a home network or running a business, this small automation can make a big difference.

Start experimenting today and make Wi-Fi sharing smarter, faster, and more secure!

Saturday, April 11, 2026

Check RAM (Memory) Usage Using Python: A Complete Guide

 

Check RAM (Memory) Usage Using Python: A Complete Guide

Monitoring system memory (RAM) is an essential task for developers, system administrators, and anyone working with performance-sensitive applications. High memory usage can slow down programs, cause crashes, or impact overall system performance. Fortunately, Python provides simple and powerful ways to check RAM usage with just a few lines of code.

In this blog, you’ll learn how to monitor memory usage in Python using different methods, from basic built-in tools to advanced libraries.

1. Why Monitor RAM Usage?

Before diving into code, it’s important to understand why memory monitoring matters:

  • Performance optimization: Identify memory-heavy processes
  • Debugging: Detect memory leaks
  • System monitoring: Keep track of overall usage
  • Efficient resource usage: Prevent crashes in large applications

2. Understanding RAM Usage

RAM (Random Access Memory) stores data temporarily while your system is running. When you run a Python program, it consumes a portion of RAM.

Key terms:

  • Total memory – Total RAM available
  • Used memory – Memory currently in use
  • Free memory – Available RAM

3. Using psutil Library (Best Method)

The most popular way to check RAM usage in Python is by using the psutil library.

Installation

pip install psutil

Check Overall System Memory

import psutil

memory = psutil.virtual_memory()

print("Total:", memory.total)
print("Available:", memory.available)
print("Used:", memory.used)
print("Percentage:", memory.percent)

Output Example

Total: 8589934592
Available: 4294967296
Used: 4294967296
Percentage: 50.0

Convert Bytes to GB

def to_gb(bytes_value):
    return bytes_value / (1024 ** 3)

print("Total RAM:", to_gb(memory.total), "GB")

4. Check Memory Usage of a Specific Process

You can also monitor how much RAM a particular Python program is using.

import psutil
import os

process = psutil.Process(os.getpid())
print("Memory Used:", process.memory_info().rss)

This returns memory usage in bytes for the current process.

5. Using os and resource (Linux/Mac)

For Unix-based systems, you can use built-in modules.

import resource

usage = resource.getrusage(resource.RUSAGE_SELF)
print("Memory usage:", usage.ru_maxrss)

Note: This method may not work on Windows.

6. Using tracemalloc for Memory Tracking

Python also provides a built-in module called tracemalloc for tracking memory allocations.

import tracemalloc

tracemalloc.start()

# Example code
a = [i for i in range(100000)]

current, peak = tracemalloc.get_traced_memory()

print("Current memory:", current)
print("Peak memory:", peak)

tracemalloc.stop()

7. Monitoring Memory in Real-Time

You can continuously track RAM usage using a loop:

import psutil
import time

while True:
    memory = psutil.virtual_memory()
    print(f"RAM Usage: {memory.percent}%")
    time.sleep(1)

This is useful for real-time monitoring tools.

8. Creating a Simple RAM Monitor Script

Here’s a simple script combining everything:

import psutil

def check_ram():
    memory = psutil.virtual_memory()
    
    print("Total RAM:", round(memory.total / (1024**3), 2), "GB")
    print("Used RAM:", round(memory.used / (1024**3), 2), "GB")
    print("Free RAM:", round(memory.available / (1024**3), 2), "GB")
    print("Usage:", memory.percent, "%")

check_ram()

9. Use Cases in Real Projects

1. Web Applications

Monitor memory usage to prevent server crashes.

2. Data Science

Track RAM while handling large datasets.

3. Automation Scripts

Ensure scripts don’t consume excessive resources.

4. Game Development

Optimize performance by managing memory efficiently.

10. Performance Tips

  • Avoid storing large unnecessary data in memory
  • Use generators instead of lists
  • Free unused variables using del
  • Use memory profiling tools

11. Common Issues and Solutions

High Memory Usage

  • Optimize data structures
  • Use efficient algorithms

Memory Leaks

  • Check for unused references
  • Use tracemalloc to debug

Slow Performance

  • Monitor both CPU and RAM usage
  • Optimize loops and logic

12. Comparison of Methods

Method Ease of Use Platform Support Best For
psutil ⭐⭐⭐⭐⭐ All platforms General use
resource ⭐⭐ Linux/Mac Basic usage
tracemalloc ⭐⭐⭐ All platforms Debugging

Conclusion

Checking RAM usage using Python is simple yet extremely powerful. Whether you're building small scripts or large-scale applications, monitoring memory helps you write efficient and stable programs.

The psutil library is the easiest and most versatile option, while tools like tracemalloc provide deeper insights into memory allocation. By combining these techniques, you can ensure your applications run smoothly without consuming unnecessary resources.

As you continue your Python journey, integrating memory monitoring into your workflow will help you build faster, smarter, and more reliable software.

Monitor Network I/O (Upload/Download) in Python: A Complete Guide

 

Monitor Network I/O (Upload/Download) in Python: A Complete Guide

In modern computing, monitoring network activity is just as important as tracking CPU or memory usage. Whether you are building a system monitoring tool, optimizing applications, or simply curious about your internet usage, Python provides powerful ways to track network input/output (I/O) — that is, data being uploaded and downloaded.

In this blog, you’ll learn how to monitor network I/O in Python using practical examples, tools, and best practices.

1. What is Network I/O?

Network I/O refers to the amount of data transferred over a network interface.

  • Download (Received) → Data coming into your system
  • Upload (Sent) → Data leaving your system

This data is usually measured in bytes, kilobytes (KB), megabytes (MB), or gigabytes (GB).

2. Why Monitor Network Usage?

Monitoring network I/O is useful for:

  • Tracking internet usage
  • Detecting unusual activity
  • Optimizing applications
  • Building monitoring dashboards
  • Troubleshooting slow networks

3. Using psutil to Monitor Network I/O

The easiest and most popular way to monitor network usage in Python is by using the psutil library.

Installation

pip install psutil

4. Basic Network I/O Monitoring

import psutil

net = psutil.net_io_counters()

print("Bytes Sent:", net.bytes_sent)
print("Bytes Received:", net.bytes_recv)

This gives total data sent and received since the system started.

5. Converting Bytes to MB

def bytes_to_mb(bytes_value):
    return bytes_value / (1024 * 1024)

print("Upload:", bytes_to_mb(net.bytes_sent), "MB")
print("Download:", bytes_to_mb(net.bytes_recv), "MB")

6. Real-Time Network Speed Monitoring

To monitor upload and download speed, you need to calculate the difference over time.

import psutil
import time

old_value = psutil.net_io_counters()

while True:
    time.sleep(1)
    new_value = psutil.net_io_counters()
    
    upload_speed = new_value.bytes_sent - old_value.bytes_sent
    download_speed = new_value.bytes_recv - old_value.bytes_recv
    
    print(f"Upload: {upload_speed / 1024:.2f} KB/s | Download: {download_speed / 1024:.2f} KB/s")
    
    old_value = new_value

This script updates every second and shows live network speed.

7. Monitor Specific Network Interfaces

If your system has multiple interfaces (Wi-Fi, Ethernet), you can monitor them separately:

net = psutil.net_io_counters(pernic=True)

for interface, stats in net.items():
    print(interface, stats.bytes_sent, stats.bytes_recv)

8. Building a Simple Network Monitor Tool

Here’s a clean and reusable script:

import psutil
import time

def monitor_network():
    old = psutil.net_io_counters()
    
    while True:
        time.sleep(1)
        new = psutil.net_io_counters()
        
        upload = (new.bytes_sent - old.bytes_sent) / 1024
        download = (new.bytes_recv - old.bytes_recv) / 1024
        
        print(f"Upload: {upload:.2f} KB/s | Download: {download:.2f} KB/s")
        
        old = new

monitor_network()

9. Use Cases in Real Projects

1. System Monitoring Dashboard

Track network performance along with CPU and RAM.

2. Data Usage Tracker

Measure how much internet you consume daily or monthly.

3. Cybersecurity

Detect unusual spikes in upload/download activity.

4. Server Monitoring

Ensure servers are handling traffic efficiently.

10. Improving Your Network Monitor

You can enhance your script by:

  • Converting speeds to MB/s or GB/s
  • Logging data to a file
  • Displaying graphs using libraries like matplotlib
  • Adding alerts for high usage

11. Performance Tips

  • Avoid very short intervals (like milliseconds)
  • Use efficient loops
  • Combine with threading for better performance
  • Monitor only required interfaces

12. Common Issues and Fixes

Values Not Changing

Ensure there is active network usage.

Incorrect Speed Calculation

Make sure the time interval is consistent.

High CPU Usage

Increase sleep time in loops.

13. Difference Between Total and Real-Time Usage

Type Description
Total Usage Data transferred since system start
Real-Time Speed Data transferred per second

Both are useful depending on your use case.

Conclusion

Monitoring network I/O in Python is simple yet extremely powerful. With just a few lines of code using psutil, you can track total data usage, measure real-time upload/download speed, and even build your own network monitoring tool.

Whether you're a developer optimizing applications, a student learning system programming, or a professional managing servers, understanding network usage gives you better control over performance and security.

Start with basic scripts, experiment with real-time monitoring, and gradually build advanced tools like dashboards or alert systems. With Python, you have everything you need to monitor and manage network activity efficiently.

ChatGPT: Both Artificial Intelligence and a Product of Machine Learning

  ChatGPT: Both Artificial Intelligence and a Product of Machine Learning In recent years, tools like ChatGPT have transformed how people i...