Programming Articles

Page 622 of 2547

Python program to split the even and odd elements into two different lists.

Yaswanth Varma
Yaswanth Varma
Updated on 24-Mar-2026 24K+ Views

In this article, we are going to learn about splitting the even and odd elements into two different lists. This involves looping through each element in a list and checking whether it is divisible by 2. Even numbers are those that give the remainder '0' when divided by 2, while the odd numbers leave a remainder '1'. Using append() Method The Python append() method is used to add a new object to a list. It accepts an object as an argument and inserts it at the end of the existing list. Syntax list.append(obj) ...

Read More

SequenceMatcher in Python for Longest Common Substring.

Yaswanth Varma
Yaswanth Varma
Updated on 24-Mar-2026 1K+ Views

The SequenceMatcher class is part of Python's difflib module. It compares sequences (such as lists or strings) and finds similarities between them. The task is to find the Longest Common Substring — the longest sequence of characters that appears contiguously in both strings. This is different from the Longest Common Subsequence, where characters may appear in the same order but not necessarily contiguous. Using find_longest_match() Method The find_longest_match() method finds the longest matching sequence of elements between two sequences. It returns a Match object with three attributes: a (start position in first sequence), b (start position in ...

Read More

Python program to find Maximum and minimum element’s position in a list?

Yaswanth Varma
Yaswanth Varma
Updated on 24-Mar-2026 15K+ Views

In Python, Lists are one of the most versatile data types. They store sequences of comma-separated items enclosed in square brackets []. Finding the maximum and minimum element positions is a common task that can be achieved using Python's built-in functions max(), min(), and index(). Understanding the Required Functions max() Function The max() function returns the largest element in a list. For numbers, comparison is done numerically; for strings, comparison is done alphabetically. max(list) min() Function The min() function returns the smallest element in a list. Like max(), it compares numbers numerically ...

Read More

Difference between == and is operator in python.

Akshitha Mote
Akshitha Mote
Updated on 24-Mar-2026 1K+ Views

In Python, the == and is operators are used for comparison, but they serve different purposes. The == operator checks for equality of values, which means it evaluates whether the values of two objects are the same. On the other hand, the is operator checks for identity, meaning it determines whether two variables point to the same object in memory. What Is the 'is' Operator? The Python is operator tests whether two variables refer to the same object in memory. If the variables refer to the same memory location, it returns True; otherwise, it returns False. This operator ...

Read More

Zip function in Python to change to a new character set.

Samual Sam
Samual Sam
Updated on 24-Mar-2026 219 Views

The zip() function in Python can be used to create a mapping between two character sets. This is useful when you want to translate text from one character encoding to another, such as converting from a custom character set back to the standard alphabet. Problem Statement Given a custom 26-letter character set and the standard alphabet, we need to create a mapping to translate strings from the custom set back to normal letters. Custom character set: qwertyuiopasdfghjklzxcvbnm Standard alphabet: abcdefghijklmnopqrstuvwxyz Input: "wwmm" Output: "bbzy" Algorithm Define the custom character ...

Read More

Python program to check if binary representation of two numbers are anagram.

Yaswanth Varma
Yaswanth Varma
Updated on 24-Mar-2026 874 Views

The binary numbers are the basis of how data is stored, processed and transferred. Every integer is internally represented by using a sequence of bits (combination of 0s and 1s). In this article, we will learn how to check if binary representation of two numbers are anagram. Two numbers are said to be binary anagrams if their binary representations contain the same number of 1s and 0s. For example, the number 12 in binary is 1100 and the number 10 in binary is 1010, both have two 0s and two 1s, making them binary anagrams. Using collections.Counter() Class ...

Read More

Print m multiplies of n without using any loop in Python.

karthikeya Boyini
karthikeya Boyini
Updated on 24-Mar-2026 323 Views

Given a number n, we can print m multiples of a step value without using any loop by implementing a recursive function. This approach uses function calls to simulate iteration. Problem Statement We need to print numbers starting from n, decreasing by a step value until we reach 0 or negative, then increasing back to the original number. Example Input: n = 15, step = 5 Output: 15 10 5 0 5 10 15 Algorithm The recursive approach works as follows: Start with the given number n and a flag ...

Read More

Python program to find missing and additional values in two lists?

Yaswanth Varma
Yaswanth Varma
Updated on 24-Mar-2026 2K+ Views

In this article, we will explore how to find missing and additional values in two lists. This type of comparison is commonly encountered in real-world scenarios such as data validation, system synchronization, and database reconciliation. The task is to determine which elements are missing in one list and what unexpected elements were received. This can be achieved by using Python's built-in data structures like sets that allow for efficient comparison operations. Understanding the Problem When comparing two lists, we need to identify: Missing values: Elements present in the first list but absent in the second list ...

Read More

Python program to check a sentence is a pangrams or not.

Samual Sam
Samual Sam
Updated on 24-Mar-2026 477 Views

A pangram is a sentence that contains every letter of the alphabet at least once. For example, "The quick brown fox jumps over the lazy dog" is a famous pangram. We can check if a sentence is a pangram using Python's set() operations. Example Input and Output Input: string = 'abc def ghi jkl mno pqr stu vwx yz' Output: Yes // contains all the characters from 'a' to 'z' Input: string = 'python program' Output: No // Does not contain all the characters from 'a' to 'z' Algorithm Here's the step-by-step approach ...

Read More

Python program to extract 'k' bits from a given position?

Chandu yadav
Chandu yadav
Updated on 24-Mar-2026 2K+ Views

Bit extraction involves extracting a specific number of bits from a given position in a number's binary representation. This is useful in low-level programming, cryptography, and data manipulation tasks. Understanding the Problem Given a number, we need to extract 'k' consecutive bits starting from a specific position 'pos' (counted from the right, starting at 0). The extracted bits are then converted back to decimal. Example Input: number=170, k=5, pos=2 Output: 21 Binary of 170: 10101010 Position 2 from right, extract 5 bits: 01010 Decimal value: 21 Algorithm The ...

Read More
Showing 6211–6220 of 25,466 articles
« Prev 1 620 621 622 623 624 2547 Next »
Advertisements