Server Side Programming Articles

Page 44 of 2109

Python – Alternate rear iteration

Pranavnath
Pranavnath
Updated on 27-Mar-2026 396 Views

Alternate rear iteration means traversing a list from the end to the beginning while selecting every alternate element. Python provides several approaches using range(), slicing, and lambda functions to achieve this efficiently. What is Alternate Rear Iteration? In alternate rear iteration, we start from the last element of a list and move backwards, picking every second element. For example, in the list [1, 2, 3, 4, 5, 6, 8], we would get [8, 5, 3, 1]. Using range() with Negative Step The range() function allows us to iterate backwards with a step of −2 to get ...

Read More

How to Find the average of two list using Python?

Pranavnath
Pranavnath
Updated on 27-Mar-2026 933 Views

Finding the average of two lists is a common task in data analysis and Python programming. Python provides several approaches including the statistics module, NumPy arrays, and basic arithmetic operations. Using the statistics Module The statistics.mean() function provides a straightforward way to calculate the average of combined lists ? import statistics # Initialize two lists numbers_1 = [56, 34, 90] numbers_2 = [23, 87, 65] # Combine lists and find average using statistics.mean() avg_of_lists = statistics.mean(numbers_1 + numbers_2) print("Average of two lists:", avg_of_lists) Average of two lists: 59.166666666666664 ...

Read More

Finding the Cartesian product of strings using Python

Pranavnath
Pranavnath
Updated on 27-Mar-2026 537 Views

The Cartesian product of strings creates all possible combinations between elements from different sets. Python provides several approaches to find the Cartesian product of strings using itertools.product(), nested loops, and lambda functions. Using itertools.product() The itertools.product() function provides the most straightforward way to generate Cartesian products ? import itertools # Define two sets of strings set1 = ["welcome", "all", "here"] set2 = ["see", "you", "soon"] # Generate Cartesian product using itertools.product() cart_product = list(itertools.product(set1, set2)) # Concatenate strings from each tuple result = [a + b for a, b in cart_product] print(result) ...

Read More

Python3 Program for Longest subsequence of a number having same left and right rotation

Shubham Vora
Shubham Vora
Updated on 27-Mar-2026 223 Views

In this problem, we will find the length of the longest subsequence of a given numeric string such that it has the same left and right rotation. A string has the same left and right rotation when rotating left by one position produces the same result as rotating right by one position. We can solve this problem using two approaches: generating all subsequences and checking rotations, or using an optimized observation-based method that recognizes patterns in valid subsequences. Problem Statement Given a numeric string, find the size of the longest subsequence that has the same left and ...

Read More

Python3 Program for Queries for Rotation and Kth Character of the given String in Constant Time

Shubham Vora
Shubham Vora
Updated on 27-Mar-2026 204 Views

In this problem, we need to perform queries on a string efficiently. We'll handle two types of queries: left rotation and character access. We'll explore two approaches - a straightforward string manipulation method and an optimized pointer-based solution. Problem Statement Given a string and an array of queries, perform operations based on query types ? (1, l) − Perform left rotation of the string l times (2, l) − Access and print the character at position l (1-indexed) Example Let's see how the queries work with a sample input ? # ...

Read More

Combining IoT and Machine Learning makes our future smarter

Mithilesh Pradhan
Mithilesh Pradhan
Updated on 27-Mar-2026 260 Views

The Internet of Things (IoT) creates networks of connected devices that collect data through sensors, while Machine Learning transforms this data into intelligent insights. Combining these technologies enables smart systems that can make autonomous decisions and adapt to changing conditions in real-time. What is IoT and Machine Learning Integration? The Internet of Things (IoT) consists of embedded devices, smart sensors, and computers that communicate through networks to collect and exchange data. These devices interact with the physical world using sensors for data collection and actuators for control operations. Machine Learning algorithms process the massive amounts of data ...

Read More

Dumping queue into list or array in Python

Prabhdeep Singh
Prabhdeep Singh
Updated on 27-Mar-2026 629 Views

A queue is a linear data structure that follows the FIFO (First In, First Out) principle. While queues only allow access to the front element, sometimes we need to convert the entire queue into a list for easier manipulation. Python provides multiple approaches to dump queue contents into a list. Creating a Queue in Python Python offers two main queue implementations: collections.deque and queue.Queue. Let's first see how a basic queue works ? from collections import deque # Create and populate a queue queue = deque() queue.append(1) queue.append(2) queue.append(3) queue.append(4) print("Queue contents:", queue) ...

Read More

Handling Missing Data in Python Causes and Solutions

Satish Kumar
Satish Kumar
Updated on 27-Mar-2026 657 Views

Missing data is a common challenge in data analysis that can significantly impact results. In Python, missing values are typically represented as NaN (Not a Number) or None. Understanding the causes and applying appropriate solutions is crucial for accurate analysis. Common Causes of Missing Data Data Entry Errors Human errors during manual data entry are frequent causes of missing values. These can include skipped fields, typos, or accidental deletions during data input processes. Incomplete Data Collection Survey non-responses, equipment failures, or incomplete forms can result in gaps in datasets. Time constraints and budget limitations may ...

Read More

Allowing resizing window in PyGame

Priya Mishra
Priya Mishra
Updated on 27-Mar-2026 2K+ Views

Pygame is a Python module for game development that provides graphics and sound libraries. By default, Pygame windows are not resizable, but you can make them resizable by adding the pygame.RESIZABLE flag. Installation of PyGame Install Pygame using pip in your terminal or command prompt ? pip install pygame Creating a Normal (Non-Resizable) Window Here's how to create a basic Pygame window that cannot be resized ? import pygame # Initialize pygame pygame.init() # Create a non-resizable window screen = pygame.display.set_mode((400, 300)) pygame.display.set_caption('Non-Resizable Window') # Main game loop ...

Read More

Animate image using OpenCV in Python

Priya Mishra
Priya Mishra
Updated on 27-Mar-2026 2K+ Views

Animated images are sequences of static images played continuously to create dynamic visual content. They're smaller than videos and widely supported across web and mobile platforms. OpenCV provides powerful tools to create animated effects by manipulating image sequences in Python. What is OpenCV? OpenCV (Open Source Computer Vision Library) is a comprehensive library for computer vision, machine learning, and image processing. Originally developed by Gary Bradsky at Intel in 1999, it now supports multiple programming languages including Python, C++, and Java across various platforms. OpenCV provides extensive functionality for image manipulation, video processing, and real-time computer vision ...

Read More
Showing 431–440 of 21,090 articles
« Prev 1 42 43 44 45 46 2109 Next »
Advertisements