Pavitra

Pavitra

123 Articles Published

Articles by Pavitra

Page 13 of 13

The intersection of two arrays in Python (Lambda expression and filter function )

Pavitra
Pavitra
Updated on 07-Aug-2019 763 Views

In this article, we will learn about the intersection of two arrays in Python with the help of Lambda expression and filter function.The problem is that we are given two arrays we have to find out common elements in both of them.Algorithm1. Declaring an intersection function with two arguments. 2. Now we use the lambda expression to create an inline function for selection of elements with the help of filter function checking that element is contained in both the list or not. 3. Finally, we convert all the common elements in the form of a list by the help of ...

Read More

Inplace Operators in Python - ixor(), iand(), ipow()

Pavitra
Pavitra
Updated on 07-Aug-2019 335 Views

In this article, we will learn about some of the inplace operators available in Python 3.x. Or earlier.Python provides methods to perform inplace operations, i.e assignment and computation simultaneously using in a single statement with the help of “operator” module. Here we will discuss about ixor(), iand(), ipow() functions .ixor()This function allows us to assign and xor current value. This operation behaves like “a^=b” operation. Assigning can’t be performed in case of immutable data types, such as strings and tuples.Exampleimport operator as op # using ixor() to xor int1 = op.ixor(786, 12); # displaying value print ("The value ...

Read More

Initialize Matrix in Python

Pavitra
Pavitra
Updated on 07-Aug-2019 4K+ Views

In this article, we will learn about how we can initialize matrix using two dimensional list in Python 3.x. Or earlier.Let’s see the intuitive way to initialize a matrix that only python language offers. Here we take advantage of List comprehension. we initialise the inner list and then extend to multiple rows using the list comprehension.Example# input the number of rows N = 3 # input the number of columns M = 3 # initializing the matrix res = [ [ i*j for i in range(N) ] for j in range(M) ] # printing the matrix on screen row ...

Read More
Showing 121–123 of 123 articles
« Prev 1 9 10 11 12 13 Next »
Advertisements