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
Dictionary Methods in Python (cmp(), len(), items()...)
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 MoreIs there any selector for elements containing certain text in CSS?
To select elements containing certain text in CSS, we can use CSS attribute selectors. We can either use pre-defined attributes or add custom attributes in the HTML document. Syntax /* Exact match */ [attribute="value"] { } /* Contains word */ [attribute~="word"] { } /* Contains substring */ [attribute*="substring"] { } /* Starts with */ [attribute^="prefix"] { } /* Ends with */ [attribute$="suffix"] { } Method 1: Using Attribute Value Selector The attribute value selector [attribute="value"] selects elements with an exact attribute value match − ...
Read MoreFind the first repeated word in a string in Python using Dictionary
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 MoreDifferent messages in Tkinter - Python
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 MoreHow to specify order of classes using CSS?
Cascading Style Sheets (CSS) is a powerful component of web development which enables the developers to determine the visual appearance of their websites. In CSS, classes are used as selectors which enables us to apply several specific styles to an element. You can also use multiple classes for a particular element. However, when you apply multiple classes to an element, it is necessary to know how to specify the order of these classes in which they will be rendered to avoid discrepancies and unexpected results. In this article, we will discuss different methods to specify the order of classes ...
Read Moredestroy() method in Tkinter - Python
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 MoreHow to create Paradoxical effect using CSS?
The Paradoxical effect is a visual effect used to create optical illusions where elements appear to move or behave in contradictory ways. This effect can add interesting and unique elements to your web pages by using CSS properties that create unexpected visual behaviors. This can be easily achieved using HTML and CSS combinations. In this article, we will explore techniques for creating paradoxical effects using CSS properties that work against each other, resulting in visually intriguing contradictions and animations. Syntax selector { property1: value1; property2: contradictory-value; ...
Read MoreCreate a stopwatch using python
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 MoreHow to apply multiple transform property to an element using CSS?
The CSS transform property allows you to apply multiple transformations to an element simultaneously. You can combine different transform functions like rotate(), scale(), and translate() to create complex visual effects. Syntax selector { transform: function1(value) function2(value) function3(value); } Method 1: Multiple Transform Functions in Single Declaration The most efficient way to apply multiple transformations is by combining transform functions in a single declaration separated by spaces − Example This example applies rotation and scaling transformations on hover − ...
Read MoreFind all the patterns of "1(0+)1" in a given string using Python Regex
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