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
How to Align Labels Next to Inputs?
When designing web forms, aligning labels next to input fields can significantly improve readability and usability. This alignment enhances the form's visual structure, making it easier for users to fill out information. In this article, we'll cover CSS techniques for aligning labels both to the right and left of their respective input fields. Syntax label { display: inline-block; width: value; text-align: left | right; } Basic CSS Properties for Label Alignment The key properties for aligning labels are: PropertyPurposeCommon Values ...
Read MorePython - Difference in keys of two dictionaries
Two Python dictionaries may contain some common keys between them. In this article we will find how to get the difference in the keys present in two given dictionaries. Using Set Difference Here we take two dictionaries and apply set function to them. Then we subtract the two sets to get the difference. We do it both ways, by subtracting second dictionary from first and next subtracting first dictionary from second. Those keys which are not common are listed in the result set ? Example dictA = {'1': 'Mon', '2': 'Tue', '3': 'Wed'} print("1st Dictionary:", ...
Read MoreImage Clip Animation with Sliders using only HTML & CSS
Creating an animated image clip with a slider using only HTML and CSS provides an interactive way to display multiple images with smooth circular clip-path transitions. In this tutorial, we'll create an image carousel where each image reveals with a circular animation effect controlled by stylish radio button sliders. Syntax .element { clip-path: circle(radius at position); transition: clip-path duration ease; } input[type="radio"]:checked ~ .target { clip-path: circle(150% at 0% 100%); } Project Setup You'll need to set up basic HTML and ...
Read MorePython - Create a dictionary using list with none values
Sometimes you need to create a dictionary from a list where each list element becomes a key with a None value. This is useful for creating placeholder dictionaries or initializing data structures. Python provides several methods to achieve this conversion. Using dict.fromkeys() The dict.fromkeys() method creates a dictionary with keys from an iterable and assigns the same value to all keys. By default, it assigns None ? days = ["Mon", "Tue", "Wed", "Thu", "Fri"] print("Given list:") print(days) result = dict.fromkeys(days) print("Dictionary with None values:") print(result) Given list: ['Mon', 'Tue', 'Wed', 'Thu', ...
Read MorePython - Convert given list into nested list
Sometimes we need to convert list elements into individual sublists, creating a nested list structure. Python provides several approaches to achieve this transformation depending on your specific requirements. Using List Comprehension The simplest approach is to wrap each element in a list using list comprehension ? days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] print("Given list:", days) # Convert each element to a sublist nested_list = [[item] for item in days] print("Nested list:", nested_list) Given list: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] Nested list: [['Mon'], ['Tue'], ['Wed'], ['Thu'], ['Fri']] Using map() Function ...
Read MoreBroadcasting with NumPy Arrays in Python
Broadcasting is a NumPy feature that allows arithmetic operations between arrays of different shapes without explicitly reshaping them. When arrays have unequal dimensions, NumPy automatically adjusts the smaller array's shape by prepending dimensions of size 1, enabling element-wise operations. Rules of Array Broadcasting NumPy follows these rules when broadcasting arrays ? Arrays with smaller ndim are prepended with dimensions of size 1 in their shape. The output shape in each dimension is the maximum of the input sizes in that dimension. An array can be used in calculation if its size in a particular dimension matches ...
Read MoreInput Label Animation in HTML & CSS
The CSS input label animation creates a smooth floating effect where the label moves to the top border of the input field when the user focuses on or types in the input. This provides better user experience and visual feedback. Syntax /* Basic structure for animated label */ .input-container { position: relative; } label { position: absolute; transition: all 0.3s ease; pointer-events: none; } /* Animation trigger */ input:focus + label, input:not(:placeholder-shown) + label { ...
Read MoreDouble Click Heart Animation in HTML CSS & JavaScript
The double-click heart animation is a popular interactive effect commonly seen on social media platforms. This article demonstrates how to create this engaging animation using HTML, CSS, and JavaScript, where users can double-click anywhere on a container to display an animated heart at that specific position. Syntax /* CSS Animation Syntax */ @keyframes animation-name { 0% { /* initial state */ } 50% { /* middle state */ } 100% { /* final state */ } } .element { animation: ...
Read MoreAvoiding class data shared among the instances in Python
When we create multiple instances of a class in Python, class variables are shared among all instances. This can lead to unexpected behavior when modifying mutable objects like lists or dictionaries. In this article, we will explore the problem and two effective solutions to avoid shared class data. The Problem: Shared Class Variables In the below example, we demonstrate how class variables are shared across all instances, leading to unintended data sharing ? class MyClass: listA = [] # This is a class variable, shared by all instances # Instantiate ...
Read MoreAverage of each n-length consecutive segment in a Python list
We have a list containing only numbers. We plan to get the average of a set of sequential numbers from the list which keeps rolling from the first number to next number and then to next number and so on. Example The below example simplifies the requirement of finding the average of each 4-length consecutive elements of the list ? Given list: [10, 12, 14, 16, 18, 20, 22, 24, 26] Average of every segment of 4 consecutive numbers: [13.0, 15.0, 17.0, 19.0, 21.0, 23.0] Using sum() and range() We use the ...
Read More