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 on Trending Technologies
Technical articles with clear explanations and examples
Python program to convert floating to binary
A floating-point number is a number that has a decimal point and can represent both large and very small values. Binary representation uses only 0's and 1's in the base-2 numeral system. Converting floating-point numbers to binary in Python requires representing them in the IEEE 754 format (a standard for numerical representation using 1 bit for sign, 8 bits for exponent, and 23 bits for significand in 32-bit format). For example, the floating number 9.87 has the IEEE 754 32-bit binary representation "01000001000111011110101110000101". In this article, we will discuss different ways to convert floating-point numbers to binary using ...
Read MoreGet similar words suggestion using Enchant in Python
There will be times when we misspell some words when we write something. To overcome this problem, we use the PyEnchant module in Python. This module is used to check the spelling of words and suggest corrections for misspelled words. It is also used in many popular spell checkers, including ispell, aspell, and MySpell. It is very flexible in handling multiple dictionaries and multiple languages. For example, if the input is 'prfomnc', then the output returned would be − 'prominence', 'performance', 'preform', 'provence', 'preferment', 'proforma'. Installing PyEnchant For Windows users, install the pre-built binary packages using ...
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 MoreText Analysis in Python3
Text analysis involves extracting meaningful information from text files. Python provides powerful built-in functions to analyze various aspects of text data, including word counts, character statistics, and linguistic patterns. Text Analysis Functions • Word Count • Characters • Average Length • Stop Words • Special Chars • Numeric Data Reading Text Files First, let's create a sample text file and establish the basic file reading pattern ? # Create a sample text file sample_text = """Python ...
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 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 More