Found 10784 Articles for Python

__getitem__ and __setitem__ in Python

Tushar Sharma
Updated on 09-May-2023 15:41:44

2K+ Views

Have you ever considered how Python's magic methods make our lives as programmers less complicated, almost as if we've got a helpful buddy guiding us along the way? In this article, we're going to explore Python's magic methods, getitem, and setitem, unraveling their mysteries and coming across how they are able to assist us to write extra expressive, human-friendly code. Let's dive in! Understanding Magic Methods Magic methods, additionally called "dunder" methods (short for "double underscore"), are unique strategies in Python classes that have double underscores at the beginning and cease of their names. They permit us to define how ... Read More

__future__ Module in Python

Tushar Sharma
Updated on 09-May-2023 15:40:45

203 Views

As a programmer, have you ever felt like you've been emitted to destiny, wherein you may explore the exciting functions of a new version of your preferred programming language? Well, if you're a Python enthusiast, you're in good fortune! The future module in Python is here to present you with a flavor of the destiny, or at the least a preview of the upcoming capabilities. In this article, we'll embark on a journey together, exploring the fine details of the destiny module in Python, and how it allows us to stay in advance of the sport while still maintaining compatibility ... Read More

Full outer join in PySpark dataframe

Atharva Shah
Updated on 08-May-2023 16:54:04

2K+ Views

A Full Outer Join is an operation that combines the results of a left outer join and a right outer join. In PySpark, it is used to join two dataframes based on a specific condition where all the records from both dataframes are included in the output regardless of whether there is a match or not. This article will provide a detailed explanation of how to perform a full outer join in PySpark and provide a practical example to illustrate its implementation. Installation and Setup Before we can perform a full outer join in PySpark, we need to set up ... Read More

Python Program to Rotate Elements of an Array

Nikhitha Chowdary Manne
Updated on 08-May-2023 15:42:00

741 Views

After the declaration of an array, the elements of the array until certain index are rotated such that the first elements until the desired index are placed in the last, next to the last element of the array. Let us discuss this with an Input output scenario. Input Output Scenario Consider an array arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]. We can clearly say that the initial array consists of 10 elements and the index of the last element is 9. Let us assume that the array is rotated by two elements. ... Read More

Python program to print an Array

Nikhitha Chowdary Manne
Updated on 08-May-2023 15:40:42

2K+ Views

The collection of homogenous elements within a single variable and in the contiguous memory location is known as array. The elements in array can be of any datatype but all the elements that are present in the array should be homogeneous, i.e., should belong to the same datatype. The arrays are a kind of special variables which actually store several values or elements in the name of a single variable with continuous memory locations which are accurately known as “ indices ”. Indices The word indices represents the plural form of index. The word index denotes the position of the ... Read More

Python Program to Sort the 2D Array Across Columns

Nikhitha Chowdary Manne
Updated on 08-May-2023 15:39:12

2K+ Views

When a two dimensional array or a 2D array is declared, it is treated like a matrix. So, we know that a matrix consists of rows and columns. The process of sorting the elements that belong to a particular column of a matrix either in ascending order or in descending order is known as sorting a 2D array across columns. Let us consider an algorithm followed by an Input output scenario to understand the exact application of this concept. Input Output Scenario Consider a two dimensional array. arr = [[ 7, 9, 5, 7 ], [9, 5, 9, 4], ... Read More

Python Program to Search an element in an Array

Nikhitha Chowdary Manne
Updated on 08-May-2023 15:33:42

5K+ Views

In Python, there are mainly two searching algorithms that are majorly used. Out of those, the first one is Linear Search and the second one is Binary Search. These two techniques are majorly used in order to search an element from the given array or from the given list also. While searching an element, there are two methodologies that can be followed in any kind of algorithm. One of those is recursive approach and the other is iterative approach. Let us discuss both algorithms in both approaches and solve similar problems. Linear Search The Linear Search technique is also known ... Read More

Python Program to Remove the last element from an Array

Nikhitha Chowdary Manne
Updated on 08-May-2023 13:28:59

5K+ Views

There are three different ways in order to delete or remove the element. Let us discuss some of those methods and keywords that are used to remove the last element from an array one after another in a row. Using Delete() Method of the Numpy Module This module can be used in order to delete an element of an array when an index is clearly specified. This operation can be done by the delete() method that belongs to the module numpy. But, in order to use that delete method, the array should be created in the form ... Read More

Python Program to Remove the first element from an Array

Nikhitha Chowdary Manne
Updated on 08-May-2023 15:32:20

2K+ Views

In order to remove the first element of the array, the index that must be considered is 0 as the index of the first element in any array is always 0. As like removing the last element from an array, removing the first element from the array can be processed using the same techniques. Let us apply those techniques in the deletion of first element of the array. We shall discuss the methods and keywords that are used to remove the first element from an array one after another in a row now. Using the pop() Method The method pop() ... Read More

Python Program to Remove Duplicate Elements From an Array

Nikhitha Chowdary Manne
Updated on 16-May-2023 09:42:50

538 Views

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

Advertisements