Server Side Programming Articles

Page 52 of 2109

Python - K difference index Pairing in List

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 309 Views

K difference index pairing creates pairs of elements from a list where each element is paired with another element that is exactly K positions ahead. For example, with K=2, element at index 0 pairs with element at index 2, index 1 with index 3, and so on. Given the list ["A", "B", "C", "D", "E", "F"] and K=2, the result would be ["AC", "BD", "CE", "DF"]. Using map() with operator.concat The map() function applies operator.concat to corresponding elements from two sliced lists ? import operator # Initialize list my_list = ["T", "U", "T", "O", ...

Read More

Python - Filter Tuples with All Even Elements

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 413 Views

Filtering tuples with all even elements is a common operation in Python data processing. This involves checking if every element in each tuple is divisible by 2 and keeping only those tuples that satisfy this condition. Using List Comprehension with all() The most Pythonic approach combines list comprehension with the all() function to filter tuples where every element is even ? tuple_list = [(6, 4, 2, 8), (5, 6, 7, 6), (8, 0, 2), (7, ), (2, 4, 6)] result = [tup for tup in tuple_list if all(ele % 2 == 0 for ele in ...

Read More

Check if a Word is Present in a Sentence

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 1K+ Views

In Python, checking if a word is present in a sentence is a common task in text processing and string manipulation. Python provides multiple approaches including the in operator, find() method, and split() method for word-by-word matching. Using the in Operator The simplest way to check if a word exists in a sentence is using Python's in operator ? sentence = "The bestseller book is amazing" word = "book" if word in sentence: print("The given word is present in the sentence.") else: print("The given word is not ...

Read More

Check if a number with even number of digits is palindrome or not

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 497 Views

A palindrome is a number that reads the same forwards and backwards. This article shows how to check if a number with an even number of digits is a palindrome in Python. Examples include 2662, 4224, 44, 1001, etc. Using String Comparison The simplest approach converts the number to a string and compares it with its reverse ? def is_even_digit_palindrome(num): # Convert number to string num_str = str(num) # Check if even number of digits ...

Read More

Python - K List Dictionary Mesh

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 254 Views

The term dictionary mesh refers to creating a nested dictionary structure where each element from the first list becomes a key, and each element from the second list becomes a nested key with empty lists as values. This creates a mesh-like structure that can hold organized data. Understanding Dictionary Mesh Given two input lists ? list1 = [10, 20, 30] list2 = [40, 50] The dictionary mesh creates this structure ? {10: {40: [], 50: []}, 20: {40: [], 50: []}, 30: {40: [], 50: []}} Method 1: Using Nested ...

Read More

Python Tensorflow - tf.keras.Conv2D() Function

Parth Shukla
Parth Shukla
Updated on 27-Mar-2026 928 Views

In deep learning, computer vision is one of the most important fields used for complex tasks like image analysis, object detection, and segmentation. TensorFlow and Keras provide powerful built-in functions that automate and simplify the model training process. The Conv2D function is one of the most useful tools in Keras for applying convolutional operations to images. In this article, we'll explore what Conv2D is, how to use it, and see practical examples. What are Convolutional Operations? Convolutional operations are fundamental operations used in Convolutional Neural Networks (CNNs) to extract features from input image data. These operations use ...

Read More

Compute Classification Report and Confusion Matrics in Python

Parth Shukla
Parth Shukla
Updated on 27-Mar-2026 1K+ Views

In machine learning, classification problems require careful evaluation to understand model performance. The classification report and confusion matrix are essential tools that help us evaluate classification models and identify where they make mistakes. This article will explore these evaluation methods through practical Python examples, covering their components, interpretation, and implementation using scikit-learn. What is a Confusion Matrix? A confusion matrix is a table that summarizes the performance of a classification model by comparing predicted vs. actual values. It contains four key components ? True Positive (TP): Model correctly predicts positive class True Negative (TN): Model ...

Read More

Python - K Elements Reversed Slice

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 326 Views

K Elements Reversed Slice extracts the last K elements from a list and returns them in reverse order. This technique is useful for data analysis, queue processing, and extracting recent entries from datasets. What is K Elements Reversed Slice? A K elements reversed slice takes the last K elements from a list and reverses their order. For example, if we have [1, 2, 3, 4, 5] and K=3, we get the last 3 elements [3, 4, 5] reversed as [5, 4, 3]. Using Slicing The most concise approach uses Python's slice notation with negative indexing and ...

Read More

Python - Filter unequal elements of two lists corresponding same index

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 699 Views

When working with two lists in Python, you may need to find elements that are equal at the same index positions. This is useful for data comparison, synchronization, and filtering operations. For example, given two lists: list1 = [10, 20, 30, 40, 50] list2 = [1, 20, 3, 40, 50] # Elements at same index: 20, 40, 50 are equal Using zip() and List Comprehension The most Pythonic approach uses zip() to pair elements and list comprehension to filter matches − list1 = [1, 2, 3, 4, 5] list2 = [1, 2, ...

Read More

Finding Words with both Alphabet and Numbers using Python

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 874 Views

Finding words that contain both alphabetic characters and numeric digits is a common text processing task in Python. This tutorial demonstrates four different approaches using built-in functions like filter(), isdigit(), isalpha(), and regular expressions. Problem Overview Given a text string, we need to extract words that contain both letters and numbers ? Input my_text = "WELCOME TO CLUB100" print("Input:", my_text) Input: WELCOME TO CLUB100 Expected Output ['CLUB100'] Method 1: Using Regular Expressions Regular expressions provide a powerful pattern-matching approach to find words containing both letters and digits ...

Read More
Showing 511–520 of 21,090 articles
« Prev 1 50 51 52 53 54 2109 Next »
Advertisements