Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Samual Sam
Page 2 of 151
Simple Chat Room using Python
In this article we will see how to make a server and client chat room system using Socket Programming with Python. The sockets are the endpoints of any communication channel. These are used to connect the server and client. Sockets are Bi-Directional. In this tutorial, we will setup sockets for each end and create a chatroom system among different clients through the server. The server side has some ports to connect with client sockets. When a client tries to connect with the same port, then the connection will be established for the chat room. There are basically two ...
Read MoreSend mail with attachment from your Gmail account using Python
In this article, we will see how to send email with attachments using Python. To send mail, we do not need any external library. There is a module called smtplib, which comes with Python. It uses SMTP (Simple Mail Transfer Protocol) to send the mail and creates SMTP client session objects for mailing. SMTP needs valid source and destination email IDs, and port numbers. The port number varies for different sites. For Gmail, the port is 587. Required Modules We need to import the following modules ? import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text ...
Read MoreImplementing Photomosaics in Python
A photomosaic is a technique where an image is divided into a grid of squares, with each square replaced by other images or colored blocks. When viewed from a distance, the original image is visible, but up close, you see individual colored tiles creating the mosaic effect. In Python, we can create photomosaics using the photomosaic module, which provides an easy way to generate stunning mosaic effects from any image. Installation Install the photomosaic module using pip ? pip install photomosaic This will also install the required scikit-learn dependency. Key Features ...
Read MoreAddition and Blending of images using OpenCv in Python
OpenCV allows us to perform mathematical operations on images by treating them as matrices. When working with images, we deal with different matrix types: binary images (0, 1), grayscale images (0-255), or RGB images (0-255 for each channel). To add two images, we simply add their corresponding matrices element-wise. OpenCV provides the cv2.add() function for image addition and cv2.addWeighted() for blending. Both operations require images of the same dimensions. Addition of Two Images The cv2.add() function performs pixel-wise addition of two images. If the sum exceeds 255, it gets clipped to 255 (saturation arithmetic) ? ...
Read MoreFetching top news using news API in Python
The News API is a popular service for searching and fetching news articles from various websites. Using this API, you can retrieve top headlines from news sources like BBC, CNN, and others. To use the News API, you need to register for a free API key at newsapi.org. Setting Up News API First, install the required library and get your API key ? pip install requests Register at newsapi.org to get your free API key. Replace "your_api_key_here" with your actual key. Fetching Top Headlines Here's how to fetch top news headlines from ...
Read MorePython Implementation of automatic Tic Tac Toe game using random number
This automatic Tic Tac Toe game simulates two players making random moves without human input. The game uses NumPy for board representation and random module for move selection, displaying the board after each turn until someone wins or the game draws. Required Modules The game requires NumPy for matrix operations and random for automated move selection ― import numpy as np import random from time import sleep Complete Implementation Here's the complete automatic Tic Tac Toe game with proper error handling ― import numpy as np import random from time import ...
Read MoreMorse Code Translator in Python
Morse Code is a communication system that converts text into sequences of dots and dashes. Named after Samuel F. B. Morse, this encoding method represents each letter and number with a unique combination of short signals (dots) and long signals (dashes). The system is widely used in telecommunications and cryptography. Each character in the English alphabet corresponds to a specific pattern of dots (.) and dashes (-). Morse Code Dictionary Here's the complete mapping of characters to Morse code patterns ? 'A':'.-', 'B':'-...', 'C':'-.-.', 'D':'-..', ...
Read MoreMultiprocessing In Python
Multiprocessing in Python allows you to execute multiple processes simultaneously, utilizing multiple CPU cores for improved performance. The multiprocessing module provides tools to create and manage separate processes that can run concurrently. Basic Process Creation To create a process, import the Process class and define a target function ? from multiprocessing import Process def display(): print('Hi !! I am Python') if __name__ == '__main__': p = Process(target=display) p.start() p.join() Hi !! I am Python ...
Read MoreSynchronization and Pooling of processes in Python
Python's multiprocessing module provides tools for synchronization and process pooling to handle concurrent execution. Synchronization ensures processes don't interfere with each other, while pooling manages multiple worker processes efficiently. Synchronization Between Processes The multiprocessing package supports spawning processes using an API similar to the threading module. It works on both Windows and UNIX operating systems and provides synchronization primitives to coordinate between processes. Example Here's how to use a Lock to synchronize output from multiple processes ? from multiprocessing import Process, Lock def my_function(lock, num): lock.acquire() ...
Read MorePlotting solar image in Python
Python provides the SunPy package for working with solar physics data and creating solar images. This package includes various solar datasets from observatories and labs, containing proton/electron flux data and imaging data. You can install SunPy using the following command ? pip install sunpy What is AIA? The Atmospheric Imaging Assembly (AIA) is an instrument aboard the Solar Dynamics Observatory (SDO) that captures high-resolution images of the Sun's atmosphere in multiple wavelengths. The AIA provides crucial data for understanding solar activity and space weather. Creating a Solar Map SunPy uses the Map ...
Read More