Programming Articles

Page 133 of 2547

Python Program to Remove Duplicate Elements From an Array

Nikhitha Chowdary Manne
Nikhitha Chowdary Manne
Updated on 27-Mar-2026 2K+ Views

An array is a collection of elements of the same data type, where each element is identified by an index value. It is the simplest data structure where each data element can be accessed directly using its index number. Arrays in Python Python does not have a specific data structure to represent arrays. Here, we can use a List as an array ? [6, 4, 1, 5, 9] 0 1 2 3 4 The indexing in Python starts from 0. In the above example, the integers 6, 4, 1, ...

Read More

Python Program to Remove All Occurrences of an Element in an Array/List

Nikhitha Chowdary Manne
Nikhitha Chowdary Manne
Updated on 27-Mar-2026 5K+ Views

An array is a collection of elements of homogeneous datatypes stored in contiguous memory locations. Python does not provide built-in arrays, but you can use lists or import the array module. Lists are more flexible as they can contain different data types. The task is to remove all occurrences of a specific element from a list, including duplicates. Let's explore different approaches to accomplish this ? Input Output Scenario Consider a list with repeated elements ? my_list = [1, 10, 20, 10, 21, 16, 18, 10, 22, 10, 8, 10] print("Original list:", my_list) print("Element 10 ...

Read More

Python program to print the Boundary elements of a Matrix

Nikhitha Chowdary Manne
Nikhitha Chowdary Manne
Updated on 27-Mar-2026 902 Views

The boundary elements of a matrix are elements located on the outer edges: first row, last row, first column, or last column. These elements form the perimeter of the matrix. Understanding Boundary Elements Consider this 3×3 matrix ? 9 8 7 6 5 4 3 2 1 The boundary elements are: 9, 8, 7, 6, 4, 3, 2, 1. The middle element 5 is not a boundary element since it's surrounded by other elements. Algorithm Step 1 − Traverse the matrix using nested loops (outer ...

Read More

What is the Best Python Library for Hidden Markov Models?

Tushar Sharma
Tushar Sharma
Updated on 27-Mar-2026 3K+ Views

Hidden Markov Models (HMMs) are powerful statistical models used for modeling sequential data with hidden states. They find applications in speech recognition, natural language processing, finance, and bioinformatics. Python offers several specialized libraries for implementing HMMs, each with unique strengths and limitations. Understanding Hidden Markov Models Before exploring the libraries, let's understand HMMs fundamentals. An HMM represents a system that transitions between hidden states over time, consisting of: A set of hidden states An initial state probability distribution A state transition probability matrix An observation probability matrix The goal is to infer the most ...

Read More

What are the Resources for Learning Advanced Python Programming?

Tushar Sharma
Tushar Sharma
Updated on 27-Mar-2026 417 Views

Python's demand as a programming language has driven it to a wealth of resources for learning its different aspects. While beginners have various tutorials and guides to help them get started, advanced learners often struggle to find resources that cater to their specific needs. In this article, we'll explore the range of resources aimed at taking your Python skills to the next level, covering topics such as advanced language features, design patterns, performance optimization, and more. Advanced Python Language Features To get the most out of Python, it's important to master its advanced language features. These features enable ...

Read More

What are Some Interesting Python Programs?

Tushar Sharma
Tushar Sharma
Updated on 27-Mar-2026 366 Views

Python is a versatile programming language known for its simplicity and readability, making it a popular choice for a wide range of applications. In this article, we'll explore seven interesting Python programs that showcase the language's power and can inspire you to create your own unique projects. These programs cover various domains including machine learning, web development, data visualization, and more. DeepArt: Neural Style Transfer with Python DeepArt is a fascinating application that combines art and technology using neural style transfer. This technique allows you to apply the style of one image (such as a painting) to the ...

Read More

__file__ (A Special Variable) in Python

Sarika Singh
Sarika Singh
Updated on 27-Mar-2026 4K+ Views

The __file__ variable in Python is a special attribute that stores the path to the current script or module from which it is accessed. It is automatically set by the Python interpreter when a script is executed or a module is imported. This variable allows you to determine the exact location of the current file, irrespective of where the Python interpreter is run. Understanding __file__ Behavior The value of __file__ can be either a relative path or an absolute path, depending on how the script is executed ? For scripts that ...

Read More

__exit__ in Python

Sarika Singh
Sarika Singh
Updated on 27-Mar-2026 4K+ Views

In Python, some special methods have names that start and end with double underscores. These are called dunder methods. One such method is __exit__, which is used in context managers for cleanup tasks. Context Manager in Python Context Managers help to manage resources such as files, database connections, or network links. It sets up a temporary environment to run a block of code. When the block ends, Python closes the file or disconnects the connection automatically. This prevents unnecessary resource consumption when we leave a file open or keep a connection (such as network, database) active. ...

Read More

__call__ in Python

Sarika Singh
Sarika Singh
Updated on 27-Mar-2026 840 Views

In Python, everything is treated as an object, including integers, strings, classes, and even functions. It provides a special method named __call__ that allows an instance of a class (i.e. object) to behave like a function (i.e. we can call/invoke it). When we define the __call__ method inside a class, we can call its instance (object) using parentheses, just like a regular function. Syntax Following is the syntax to use the __call__ method inside a class − class MyClass: def __call__(self, *args, **kwargs): ...

Read More

Python program to find common array elements

Nikhitha Chowdary Manne
Nikhitha Chowdary Manne
Updated on 27-Mar-2026 355 Views

Finding common elements in arrays is a frequent task in data processing. Python provides several approaches depending on whether you're working with multi-dimensional arrays or comparing separate arrays. Finding Common Elements in Multi-Dimensional Arrays For multi-dimensional arrays, we can use the intersection_update() method with sets to find elements that appear in all sub-arrays ? Input Output Scenario Consider a 2D array with multiple sub-arrays ? arr = [[1, 2, 3, 4], [3, 4, 5, 6], [7, 8, 3, 4], [4, 9, 8, 3], [4, 3, 10, 12]] # Elements 3 and 4 appear ...

Read More
Showing 1321–1330 of 25,466 articles
« Prev 1 131 132 133 134 135 2547 Next »
Advertisements