Pradeep Elance

Pradeep Elance

317 Articles Published

Articles by Pradeep Elance

Page 28 of 32

Generating hash ids using uuid3() and uuid5() in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 2K+ Views

The universally unique identifier (UUID) is a 128-bit hexadecimal number that guarantees uniqueness within a given namespace. Python's uuid module provides uuid3() and uuid5() functions to generate hash-based UUIDs from a namespace and name string. Syntax uuid.uuid3(namespace, name) uuid.uuid5(namespace, name) Both functions take two parameters: namespace − A UUID object defining the namespace name − A string used to generate the UUID Key Differences Function Hash Algorithm Security Use Case uuid3() MD5 Lower General purpose uuid5() SHA-1 Higher Security-sensitive applications Common ...

Read More

Find frequency of each word in a string in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 11K+ Views

As a part of text analytics, we frequently need to count words and assign weightage to them for processing in various algorithms. In this article, we will explore three different approaches to find the frequency of each word in a given sentence. Using Counter from Collections The Counter class from the collections module provides an elegant way to count word frequencies. It creates a dictionary where keys are words and values are their counts ? from collections import Counter line_text = "Learn and practice and learn to practice" freq = Counter(line_text.split()) print("Word frequencies:", freq) print("Most ...

Read More

Facebook Login using Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 1K+ Views

We can use the Python package called Selenium to automate web browser interactions. In this article, we will see how to automate Facebook login using Python's Selenium package. Prerequisites Before automating Facebook login, we need to set up Selenium and a web driver. Here are the required steps ? Step 1: Install Selenium Install the Selenium package in your Python environment ? pip install selenium Step 2: Install WebDriver Download ChromeDriver from the official website or install it using webdriver-manager ? pip install webdriver-manager Finding HTML Elements ...

Read More

Dictionary Methods in Python (cmp(), len(), items()...)

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 2K+ Views

Dictionary in Python is one of the most frequently used collection data types. It is represented by key-value pairs where keys are indexed but values may not be. There are many Python built-in functions that make using dictionaries very easy in various Python programs. In this topic we will see three built-in methods: cmp(), len(), and items(). cmp() Method The cmp() method compares two dictionaries based on keys and values. It is helpful in identifying duplicate dictionaries as well as doing relational comparisons among dictionaries. Note: This method is only available in Python 2 and has been removed ...

Read More

Find the first repeated word in a string in Python using Dictionary

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 2K+ Views

In a given sentence, there may be a word which gets repeated before the sentence ends. In this Python program, we are going to find the first word that appears multiple times in a string using a dictionary approach. The logical steps we follow to get this result are: Split the given string into words separated by space Convert these words into a dictionary using collections.Counter Traverse the list of words and find the first word with frequency > 1 Using collections.Counter ...

Read More

Different messages in Tkinter - Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 547 Views

Tkinter is Python's built-in GUI toolkit that provides various message display options for user interactions and program state changes. The Message widget displays multi-line text with customizable formatting, while the messagebox module offers standard dialog boxes like confirmations, errors, and warnings. Custom Message Widget The Message widget displays text with customizable appearance ? import tkinter as tk main = tk.Tk() key = "The key to success is to focus on goals and not on obstacles" message = tk.Message(main, text=key) message.config(bg='lightblue', font=('Arial', 14, 'italic'), width=300) message.pack(padx=20, pady=20) main.mainloop() This creates a ...

Read More

destroy() method in Tkinter - Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 6K+ Views

The destroy() method in Tkinter removes a widget from the screen and frees up memory. It's essential for controlling widget behavior and cleaning up GUI components when they're no longer needed. Syntax widget.destroy() Where widget can be any Tkinter widget including windows, buttons, labels, frames, etc. Example - Button Destruction Chain This example demonstrates how buttons can destroy each other and the main window ? from tkinter import * from tkinter.ttk import * # Create main window base = Tk() base.title("Destroy Method Demo") base.geometry("300x250") # Button that closes the ...

Read More

Create a stopwatch using python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 2K+ Views

A stopwatch is used to measure the time interval between two events, usually in seconds to minutes. It has various usage like in sports or measuring the flow of heat, current etc in an industrial setup. Python can be used to create a stopwatch by using its tkinter library. This library provides GUI features to create a stopwatch showing the Start, Stop and Reset options. The key component of the program is using the label.after() method of tkinter. Syntax label.after(ms, function=None) Parameters: ms − Time in milliseconds function − Callback function to execute ...

Read More

Find all the patterns of "1(0+)1" in a given string using Python Regex

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 321 Views

In this tutorial, we will find all occurrences of the pattern "1(0+)1" in a string using Python's regex module. The re module provides powerful pattern matching capabilities for text processing. The pattern "1(0+)1" represents a literal string containing the number 1, followed by parentheses with "0+" inside, and ending with another 1. Example Input and Output Input: string = "Sample 1(0+)1 string with 1(0+)1 unnecessary patterns 1(0+)1" Output: Total number of pattern matches are 3 ['1(0+)1', '1(0+)1', '1(0+)1'] Algorithm Follow these steps to find the pattern: 1. Import the re ...

Read More

FuzzyWuzzy Python library

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 876 Views

In this tutorial, we are going to learn about the FuzzyWuzzy Python library. FuzzyWuzzy library is developed to compare strings and provides fuzzy string matching capabilities. While we have other modules like regex and difflib to compare strings, FuzzyWuzzy is unique in its approach. The methods from this library return a score out of 100 indicating how closely the strings match, instead of simple true/false or string results. Installation To work with the FuzzyWuzzy library, we need to install fuzzywuzzy and optionally python-Levenshtein for better performance − pip install fuzzywuzzy pip install python-Levenshtein The ...

Read More
Showing 271–280 of 317 articles
« Prev 1 26 27 28 29 30 32 Next »
Advertisements