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 karthikeya Boyini
Page 3 of 142
How to get synonyms/antonyms from NLTK WordNet in Python
The WordNet is a part of Python's Natural Language Toolkit. It is a large word database of English Nouns, Adjectives, Adverbs and Verbs. These are grouped into some set of cognitive synonyms, which are called synsets. To use the Wordnet, at first we have to install the NLTK module, then download the WordNet package. $ sudo pip3 install nltk $ python3 >>> import nltk >>> nltk.download('wordnet') In the wordnet, there are some groups of words, whose meaning are same. Let's explore how to extract synonyms, antonyms, and word details using NLTK WordNet. Getting Word ...
Read MoreGenerating Random id's using UUID in Python
UUID stands for Universal Unique Identifier, a Python library that generates 128-bit unique identifiers for random objects. These identifiers are guaranteed to be unique across different systems and time periods. Advantages of UUID Generates unique random IDs for objects without requiring a central authority Useful for cryptography and hashing applications Perfect for generating unique identifiers for documents, database records, and network addresses No collision risk when generating IDs across distributed systems Using uuid1() - Time-based UUID The uuid1() function generates a UUID based on the current timestamp and MAC address ? import ...
Read MoreDunder or magic methods in python
Dunder methods (also called magic methods) are special methods in Python that allow us to define how objects behave with built-in operations. These methods are identified by double underscores (__) as prefix and suffix, like __init__ or __str__. Basic Object Representation Without defining custom string representation, Python objects display their memory location ? class String: # magic method to initiate object def __init__(self, string): self.string = string # object creation my_string = String('Python') # print object location print(my_string) ...
Read MoreDraw geometric shapes on images using Python OpenCv module
OpenCV provides powerful functions to draw geometric shapes on images. This capability is essential for image analysis, annotation, and visualization tasks where you need to highlight specific regions or add visual markers. Creating a Blank Canvas First, let's create a blank image using NumPy to serve as our canvas ? import numpy as np import cv2 # Create a blank black image (350x350 pixels, 3 channels for BGR) my_img = np.zeros((350, 350, 3), dtype="uint8") cv2.imshow('Window', my_img) cv2.waitKey(0) cv2.destroyAllWindows() Drawing Lines The cv2.line() function draws straight lines between two points. It accepts these ...
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 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 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 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 MoreCreating child process using fork() in Python
The fork() function in Python allows you to create child processes by duplicating the current process. This is a fundamental concept in Unix-like systems for process management and multithreading environments. When fork() is called, it creates an exact copy of the calling process. The return value helps distinguish between parent and child processes: 0 indicates the child process, a positive value indicates the parent process (containing the child's PID), and a negative value indicates an error occurred. Understanding fork() Return Values The fork() function returns different values depending on which process you're in ? Child ...
Read MorePlay a video in reverse mode using Python OpenCv
OpenCV (Open Source Computer Vision) is a powerful library for image and video processing in Python. One interesting application is playing videos in reverse mode by manipulating the frame order. Application Areas of OpenCV Facial recognition system Motion tracking Artificial neural network Deep neural network Video streaming Installation For Windows ? pip install opencv-python For Linux ? sudo apt-get install python-opencv Steps to Play Video in Reverse Import OpenCV library (cv2) Load the video file as input Extract all frames from the video and ...
Read More