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
Programming Articles
Page 616 of 2547
Morse 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 MorePython3 - Why loop doesn't work?
In Python, using loops, we can execute a statement or a group of statements multiple times. Usually, the loop works for all conditions, but there are certain scenarios where the functionality of loops appears to be "not working" due to delays, skipping iterations, or getting stuck in infinite loops. In this article, we will understand those scenarios with examples. When sleep() Method is Used Inside Loop The sleep() method is defined in the time module and used to suspend or stop the execution of the program for a specified number of seconds. When the sleep() method ...
Read MoreUsing CX_Freeze in Python
CX_Freeze is a Python library that converts Python scripts into standalone executables. This allows you to share your Python programs with others without requiring them to install Python or additional modules on their machines. Installing CX_Freeze First, install CX_Freeze using pip ? pip install cx_Freeze Note: The correct package name is cx_Freeze, not CX_Frezze. Creating a Sample Python Program Let's create a simple Python program that we'll convert to an executable. This program fetches and parses content from a website ? import urllib.request import urllib.parse import re import time ...
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 MoreHow to create Python objects based on an XML file?
XML (Extensible Markup Language) is a markup language used to structure, store, and transfer data between systems. Python developers often need to read and process XML data in their applications. The untangle library provides a simple way to create Python objects based on an XML file. This small Python library converts an XML document into a Python object with an intuitive API. Syntax untangle.parse(filename, **parser_features) Parameters filename: Can be an XML string, XML filename, or URL parser_features: Extra arguments passed to parser.setFeature() Return Value Returns a Python object representing the parsed XML document. ...
Read MoreTweet using Python
Before using Twitter's API in Python, we need to set up Twitter developer credentials and install the required library. This guide walks through the complete process of posting tweets programmatically. Setting Up Twitter Developer Account Step 1: Verify Your Twitter Account First, you must have a Twitter profile with a verified mobile number ? Go to Settings → Add Phone → Add number → Confirm → Save. Then turn off all text notifications if desired. Step 2: Create a New App Navigate to Twitter Developer Portal → Create New App → Leave Callback URL ...
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 MoreScraping and Finding Ordered Word in a Dictionary in Python
Scraping web content and finding words with alphabetically ordered characters is a common text processing task in Python. This article shows how to fetch text data from a URL and identify words where characters are arranged in alphabetical order. Installing Required Module First, install the requests module for web scraping ? pip install requests Web Scraping Process The scraping involves these key steps ? Import the requests module Fetch data from a URL Decode the response using UTF-8 Convert the text into a list of words Finding Ordered Words ...
Read MoreUnderscore(_) in Python
In Python, the underscore (_) character has several special uses and naming conventions. Understanding these patterns helps you write more Pythonic code and follow established conventions. Single Underscore in Interpreter The Python interpreter automatically stores the result of the last expression in the special variable _ ? # In interactive Python interpreter print(10 + 5) print(_) # Access last result print(_ * 2) # Use it in calculations 15 15 30 Ignoring Values in Unpacking Use _ as a throwaway variable when you don't need certain values during ...
Read More