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
First 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 MoreHow to set the order of flexible items using CSS?
The CSS order property allows you to change the visual order of flex items without altering their position in the HTML source. This property only works on elements that are children of a flex container (an element with display: flex or display: inline-flex). NOTE − The order property only works with flex items inside a flex container. Syntax selector { order: integer; } Possible Values ValueDescription integerAny integer value (positive, negative, or zero). Default is 0. Items are arranged in ascending order of their order values. ...
Read MoreFind top K frequent elements from a list of tuples in Python
We have a list of tuples and need to find the top K elements with highest values. For example, if K is 3, we need to find the three tuples with the largest second values. Using defaultdict and sorted This approach uses defaultdict to group elements and then sorts them by value to get the top K elements. Example import collections from operator import itemgetter from itertools import chain # Input list initialization listA = [[('Mon', 126)], [('Tue', 768)], [('Wed', 512)], [('Thu', 13)], [('Fri', 341)]] # Set K K = 3 # ...
Read MoreHow to set the inset shadow using CSS?
The CSS box-shadow property creates shadows around elements, and by default applies shadows outside the element. However, by adding the inset keyword, you can create shadows that appear inside the element, giving it a recessed or indented appearance. Syntax selector { box-shadow: inset x-offset y-offset blur spread color; } Parameters ParameterDescription insetMakes the shadow appear inside the element x-offsetHorizontal shadow offset (required) y-offsetVertical shadow offset (required) blurBlur radius (optional, default is 0) spreadSpread distance (optional, default is 0) colorShadow color (optional, default is current text color) Example ...
Read More