Python program to create 3D list.

Yaswanth Varma
Updated on 24-Mar-2026 21:00:32

2K+ Views

In Python, a 3D list is also called a three-dimensional array (list of lists of lists). It can be visualized as a cube or a set of tables stacked together. It is commonly used to represent data with three indices, such as a matrix of images (height, width, depth) or storing data for multiple 2D grids. In this article, we will learn how to create a 3D list. While Python doesn't have built-in support for multi-dimensional arrays like other programming languages, we can create and manipulate 3D lists using nested lists and loops. Using Nested Loops The ... Read More

Python program to Display Hostname and IP address?

Yaswanth Varma
Updated on 24-Mar-2026 21:00:11

2K+ Views

In this article, we are going to learn how to display the hostname and IP address. Generally, the devices that connect to a network are identified by two things: Hostname: It is the name assigned to the device on a network. It helps users to identify devices in a human-readable format (e.g, mypc, desktop-pc, etc.) IP Address: It is the numerical address assigned to each device on a network, used to locate and communicate with that device. Python provides the built-in socket module for achieving this task, which ... Read More

Python program to reverse bits of a positive integer number?

Yaswanth Varma
Updated on 24-Mar-2026 20:59:56

2K+ Views

In Python, every number is represented internally as a sequence of binary digits, known as bits. In this article, we are going to learn how to reverse the bits of a positive integer number using different approaches. What is Bit Reversal? When we reverse bits of an integer value, we flip the order of its binary digits such that the least significant bit becomes the most significant bit and vice versa. Bit Reversal Example Original: 10 1 0 ... Read More

Python program to find the length of the largest consecutive 1's in Binary Representation of a given string.

Arjun Thakur
Updated on 24-Mar-2026 20:59:31

533 Views

Given a number, we need to find the length of the longest consecutive 1's in its binary representation. This problem can be solved using bit manipulation techniques. Example Input: n = 15 Output: 4 The binary representation of 15 is 1111. Algorithm The algorithm uses bit manipulation to count consecutive 1's: Step 1: Input the number Step 2: Use a counter variable to track iterations Step 3: Apply bitwise AND with left-shifted number Step 4: This reduces each sequence of 1's by one in each iteration Step 5: Count iterations until the number becomes 0 Using Bit Manipulation This method uses the property that n & (n

Python program to print the initials of a name with last name in full?

Yaswanth Varma
Updated on 24-Mar-2026 20:59:11

5K+ Views

In this article, we are going to learn how to print the initials of a name with last name in full. For example, in applications like resumes or media references, instead of writing "Sai Vamsi Srinivas", we might write "S.V. Srinivas". This kind of formatting improves readability and ensures the important part of the name (last name) is fully visible. Using Python split() and join() Methods The Python split() method splits all words in a string using a specified separator. The separator can be a space, comma, or any other character. Following is the syntax ? ... Read More

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

Yaswanth Varma
Updated on 24-Mar-2026 20:58:52

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
Updated on 24-Mar-2026 20:58:34

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
Updated on 24-Mar-2026 20:58:12

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
Updated on 24-Mar-2026 20:57:51

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
Updated on 24-Mar-2026 20:57:28

228 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

Advertisements