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
Python - Filter the negative values from given dictionary
As part of data analysis, we often encounter scenarios where we need to filter out negative values from a dictionary. Python provides several approaches to accomplish this task efficiently. Below are two common methods using different programming constructs. Using Dictionary Comprehension Dictionary comprehension provides a clean and readable way to filter negative values. We iterate through each key-value pair and include only those with non-negative values ≥ Example dict_1 = {'x': 10, 'y': 20, 'z': -30, 'p': -0.5, 'q': 50} print("Given Dictionary:", dict_1) filtered_dict = {key: value for key, value in dict_1.items() if ...
Read MoreHow to create an Animated bars using HTML and CSS?
Animated bars are visually appealing elements that simulate music equalizer bars or loading indicators. Created using HTML for structure and CSS for styling and animation, these bars use CSS transform and @keyframes properties to create smooth scaling effects. Syntax @keyframes animationName { 0% { transform: scaleY(1); } 100% { transform: scaleY(value); } } .element { animation: animationName duration infinite alternate; animation-delay: delay-time; } Example: Basic Animated Bars The following example creates a set of animated bars that ...
Read MorePython - Filter even values from a list
As part of data analysis, we often need to filter values from a list meeting certain criteria. In this article, we'll see how to filter out only the even values from a list. To identify even numbers, we check if a number is divisible by 2 (remainder is zero when divided by 2). Python provides several approaches to filter even values from a list. Using for Loop This is the simplest way to iterate through each element and check for divisibility by 2 ? numbers = [33, 35, 36, 39, 40, 42] even_numbers = ...
Read MoreAll possible permutations of N lists in Python
When we have multiple lists and need to combine each element from one list with each element from another list, we're creating what's called a Cartesian product (not permutations). Python provides several approaches to achieve this combination. Using List Comprehension This straightforward approach uses nested list comprehension to create all possible combinations. The outer loop iterates through the first list, while the inner loop iterates through the second list ? Example A = [5, 8] B = [10, 15, 20] print("The given lists:", A, B) combinations = [[m, n] for m in A for ...
Read MoreHow to create a working slider using HTML and CSS?
A CSS slider creates a slideshow animation where users can navigate between different images using navigation buttons. This component uses radio buttons, labels, and CSS :checked pseudo-selectors to control which slide is visible without JavaScript. Syntax /* Basic slider structure */ input[type="radio"]:checked ~ .slider-container { transform: translateX(-100%); } .slider-container { display: flex; transition: transform 0.3s ease; } Key Components ComponentPurpose Radio InputsTrack which slide is active (hidden from view) LabelsAct as clickable navigation buttons :checked SelectorApply styles when a radio ...
Read MoreWhy should eval be avoided in Bash, and what should I use instead?
eval is a built-in Bash command that concatenates its arguments into a single string, joins them with spaces, then executes that string as a bash command. While powerful, eval poses serious security risks and should generally be avoided. How eval Works Let's see a basic example of eval in action − $ var="echo hello" $ echo $var $ eval $var Running the above code gives us the following result − echo hello hello When eval is applied, the variable expands and gets executed as a command, no longer behaving as ...
Read MoreHow to make the cursor to hand when a user hovers over a list item using CSS?
The CSS cursor property allows you to change the appearance of the mouse cursor when hovering over HTML elements. This is especially useful for list items to indicate they are interactive or clickable. Syntax selector:hover { cursor: value; } Possible Values ValueDescription pointerA pointing hand cursor, typically used for clickable elements grabAn open hand cursor, indicating something can be grabbed grabbingA closed hand cursor, indicating something is being dragged ...
Read MoreWhat are the calling conventions for UNIX & Linux system calls on i386 and x86-64
A system call is the fundamental interface between an application and the Linux kernel. When a Unix/Linux program does file I/O, network data transfer, or invokes processes that interact with low-level instructions, system calls are involved. Making these calls usually involves using a library called glibc which contains the functions. Common System Calls Below is a list of some frequently used system calls and their purpose ? Sr.No ...
Read MoreHow to add a custom right-click menu to a webpage?
A custom right-click menu allows you to replace the browser's default context menu with your own styled menu. This provides better control over user interactions and creates a more integrated user experience. The process involves preventing the default browser behavior and displaying your custom menu at the cursor position. Syntax /* Hide custom menu by default */ #custom-menu { display: none; position: absolute; } /* JavaScript events */ document.oncontextmenu = function(event) { event.preventDefault(); /* Show custom menu */ }; ...
Read MoreLooping through the content of a file in Bash
Reading file contents line by line is a common requirement in Bash scripting. There are several approaches to accomplish this task, each with its own advantages depending on your specific needs. Creating a Sample File First, let's create a sample file to work with ? # Create the file cat > a_file.txt
Read More