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
Append multiple lists at once in Python
For various data analysis work in Python, we may need to combine many Python lists into one list. This helps process it as a single input for other parts of the program. It provides performance gains by reducing the number of loops required for processing the data further. Using + Operator The + operator does a straightforward job of joining lists together. We apply the operator between the names of the lists and store the final result in a new list. The sequence of elements in the lists is preserved. Example listA = ['Mon', 'Tue', ...
Read MoreCreating a 5 Star Skills Rating Bar using CSS
A 5-star skill rating bar is an essential element for any portfolio website in showcasing ratings and achievements. The rating bar is responsive and can be used on various devices. Here, we have used radio buttons to create an interactive rating system. Syntax .rating { font-size: 0; direction: rtl; } .rating input { display: none; } .rating label:hover, .rating label:hover ~ label, .rating input:checked ~ label { color: #f90; } Algorithm Create an HTML document ...
Read MoreGet positive elements from given list of lists in Python
Lists can be nested, meaning the elements of a list are themselves lists. In this article we will see how to extract only the positive numbers from a list of lists. The result will be a new list containing nested lists with only positive numbers. Using List Comprehension List comprehension provides a concise way to filter positive elements from nested lists. We use nested list comprehension to iterate through each sublist and filter elements greater than zero ? Example listA = [[-9, -1, 3], [11, -8, -4, 434, 0]] # Given list print("Given List ...
Read MoreFinding frequency in list of tuples in Python
When working with lists containing tuples, you may need to find how frequently a specific element appears across all tuples. Python provides several efficient methods to count occurrences of elements within tuple structures. Using count() and map() The map() function extracts elements from each tuple, then count() finds the frequency of a specific element ? # initializing list of tuples fruits_days = [('Apple', 'Mon'), ('Banana', 'Tue'), ('Apple', 'Wed'), ('Orange', 'Thu'), ('Apple', 'Fri')] # Given list print("Given list of tuples:", fruits_days) # Frequency in list of tuples freq_result = list(map(lambda i: i[0], fruits_days)).count('Apple') # ...
Read MoreCreate Horizontal Scrollable Sections in CSS
A horizontal scrollable section is a popular web design pattern used to showcase content that extends beyond the width of the viewport. This design pattern allows users to scroll horizontally, providing a unique and engaging way to display large images, galleries, timelines, maps, and other content. Syntax .container { overflow-x: auto; white-space: nowrap; } .section { display: inline-block; width: 100vw; vertical-align: top; } Key Properties PropertyValuePurpose overflow-xauto or scrollEnables horizontal scrolling white-spacenowrapPrevents ...
Read MoreFind sum of frequency of given elements in the list in Python
When working with lists containing repeated elements, we often need to find the sum of frequencies for specific items. Python provides several approaches to calculate this efficiently ? Using sum() with count() This method uses the built-in count() method to find frequency of each element and sum() to calculate the total ? chk_list = ['Mon', 'Tue'] big_list = ['Mon', 'Tue', 'Wed', 'Mon', 'Mon', 'Tue'] # Apply sum res = sum(big_list.count(elem) for elem in chk_list) # Printing output print("Given list to be analysed:") print(big_list) print("Given list with values to be analysed:") print(chk_list) print("Sum of the ...
Read MoreCreate Horizontal Scroll Snap Using HTML and CSS
To create a horizontal scroll snap, we use the CSS scroll-snap-type property to produce the snap effect. The properties scroll-snap-type and scroll-snap-align specify the type of snap behavior and the alignment of the snap points, respectively. Syntax /* Container */ .container { scroll-snap-type: x mandatory; overflow-x: scroll; } /* Items */ .item { scroll-snap-align: start | center | end; } Key Properties PropertyValueDescription scroll-snap-typex mandatoryEnables mandatory horizontal scrolling snap scroll-snap-alignstartAligns snap points to the start of each section overflow-xscrollEnables horizontal ...
Read MoreFind frequency of given character at every position in list of lists in Python
Let's consider a scenario where you have a list which is made of lists as its elements. We are interested in finding the frequency of one character at different positions of the inner lists. Below example will clarify the requirement. Consider a list of lists given below: listA = [['a', 'a', 'b'], ['a', 'c', 'b'], ['c', 'a', 'b'], ['c', 'a', 'a']] print("Original list of lists:") print(listA) Original ...
Read MoreHow do I write CSS within HTML?
CSS (Cascading Style Sheets) can be written directly within HTML documents to style and format web pages. There are three primary methods to include CSS within HTML: inline CSS, internal CSS, and a combination of both methods. Syntax /* Inline CSS */ /* Internal CSS */ selector { property: value; } Method 1: Inline CSS Inline CSS uses the style attribute directly within HTML elements. This method has the highest specificity and will override other CSS styles. Example ...
Read MoreExtract only characters from given string in Python
Sometimes strings contain a mix of letters, numbers, and special characters. When you need to extract only the alphabetic characters from such strings, Python provides several efficient methods. Using isalpha() Method The isalpha() method checks if a character is alphabetic. You can combine it with a loop and join() to extract only letters ? Example text = "Qwer34^&t%y" # Given string print("Given string:", text) # Extract characters using isalpha() result = "" for char in text: if char.isalpha(): result = "".join([result, ...
Read More