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 is border-box different from content-box?
The CSS box-sizing property controls how an element's total width and height are calculated. Understanding the difference between border-box and content-box is crucial for precise layout control. Syntax box-sizing: content-box | border-box; CSS content-box (Default) This is the default value. The width and height properties only include the content area. Padding and border are added to the outside, making the element larger than the specified dimensions. Example The following example shows content-box behavior where padding and border add to the total size − ...
Read MoreFlatten given list of dictionaries in Python
We have a list whose elements are dictionaries. We need to flatten it to get a single dictionary where all these list elements are present as key-value pairs. Using for Loop and update() We take an empty dictionary and add elements to it by reading the elements from the list. The addition of elements is done using the update() function ? listA = [{'Mon':2}, {'Tue':11}, {'Wed':3}] # printing given arrays print("Given array:", listA) print("Type of Object:", type(listA)) res = {} for x in listA: res.update(x) # Result print("Flattened object:", ...
Read MoreHow to use text as background using CSS?
Text as background creates interesting visual effects where text appears behind other content. This technique uses CSS positioning and z-index to layer text elements, making them appear as decorative background elements rather than primary content. Syntax /* Method 1: Absolute positioning */ .background-text { position: absolute; z-index: -1; } /* Method 2: Pseudo elements */ .element::before { content: "Background Text"; position: absolute; z-index: -1; } Method 1: Using Absolute Positioned Elements This method ...
Read MoreFirst occurrence of True number in Python
In this article, we will find the first occurrence of a non-zero (True) number in a given list. In Python, zero evaluates to False while non-zero numbers evaluate to True, making this a common programming task. Using enumerate() with next() The enumerate() function provides both index and value, while next() returns the first matching element ? Example numbers = [0, 0, 13, 4, 17] # Given list print("Given list:", numbers) # Using enumerate to get index of first non-zero number result = next((i for i, j in enumerate(numbers) if j), None) # ...
Read MoreHow to use font-feature-settings property in CSS?
The font-feature-settings property is used to control advanced typographic features in OpenType fonts. Advanced typographic features like swashes, small caps, and ligatures can be controlled using this CSS property. Syntax selector { font-feature-settings: "feature-tag" value; } Possible Values ValueDescription normalDefault value, uses the font's default settings "feature-tag"Four-character OpenType feature tag in quotes 1 or onEnables the specified feature 0 or offDisables the specified feature Common Feature Tags "smcp" − Small capitals "swsh" − Swashes "liga" − Common ligatures "dlig" − Discretionary ligatures "kern" − Kerning ...
Read MoreFirst Non-Empty String in list in Python
Given a list of strings, we need to find the first non-empty element. The challenge is that there may be one, two, or many empty strings at the beginning of the list, and we need to dynamically find the first non-empty string. Using next() The next() function moves to the next element that satisfies a condition. We can use it with a generator expression to find the first non-empty string ? Example string_list = ['', 'top', 'pot', 'hot', ' ', 'shot'] # Given list print("Given list:", string_list) # Using next() with generator expression ...
Read MoreHow to use font-variant-settings property in CSS?
The CSS font-variant-settings property provides low-level control over OpenType font features, allowing you to enable or disable specific typographic features like ligatures, small capitals, and number styles. This property gives you fine-grained control over font rendering. Syntax selector { font-variant-settings: "feature" value; } Possible Values ValueDescription normalDefault value, equivalent to no feature settings "feature" valueOpenType feature tag with on (1) or off (0) value inheritInherits from parent element initialSets to default value Example 1: Enabling Small Capitals The following example demonstrates using the "smcp" feature to ...
Read MoreFinding relative order of elements in list in Python
We are given a list whose elements are integers. We are required to find the relative order, which means finding the rank (position) each element would have if the list were sorted in ascending order. Using sorted() and index() We first sort the entire list and then find the index of each element in the sorted list ? Example numbers = [78, 14, 0, 11] # printing original list print("Given list is:") print(numbers) # using sorted() and index() result = [sorted(numbers).index(i) for i in numbers] # printing result print("List with relative ordering ...
Read MoreHow to set the size of specific flex-item using CSS?
In CSS, we can control the size of specific flex items using various flex properties. The CSS flexbox is used to create responsive layouts that adapt to different screen sizes by adjusting item dimensions and positioning. Syntax selector { flex-grow: number; flex-shrink: number; flex-basis: length | percentage | auto; flex: flex-grow flex-shrink flex-basis; } Key Flex Properties PropertyDescription flex-growControls how much a flex item should grow relative to other items flex-shrinkControls how much a flex item should ...
Read MoreFind whether all tuple have same length in Python
In this article, we will learn different methods to check if all tuples in a given list have the same length. This is useful when validating data structures or ensuring consistency in tuple collections. Using Manual Iteration with len() We can iterate through each tuple and compare its length to a reference value. If any tuple has a different length, we know they are not all the same ? schedule = [('Mon', '2 pm', 'Physics'), ('Tue', '11 am', 'Maths')] # Print the original list print("Given list of tuples:") print(schedule) # Check if all tuples ...
Read More