Prasad Naik has Published 74 Articles

How to find intersection between two Numpy arrays?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:37:11

3K+ Views

In this problem, we will find the intersection between two numpy arrays. Intersection of two arrays is an array with elements common in both the original arraysAlgorithmStep 1: Import numpy. Step 2: Define two numpy arrays. Step 3: Find intersection between the arrays using the numpy.intersect1d() function. Step 4: Print ... Read More

How to add a vector to a given Numpy array?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:36:06

2K+ Views

 In this problem, we have to add a vector/array to a numpy array. We will define the numpy array as well as the vector and add them to get the result arrayAlgorithmStep 1: Define a numpy array. Step 2: Define a vector. Step 3: Create a result array same as ... Read More

How to find the sum of rows and columns of a given matrix using Numpy?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:35:16

3K+ Views

In this problem, we will find the sum of all the rows and all the columns separately. We will use the sum() function for obtaining the sum.AlgorithmStep 1: Import numpy. Step 2: Create a numpy matrix of mxn dimension. Step 3: Obtain the sum of all the rows. Step 4: ... Read More

How to find the sum of all elements of a given matrix using Numpy?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:34:44

2K+ Views

In this program, we will add all the terms of a numpy matrix using the sum() function in the numpy library. We will first create a random numpy matrix and then, we will obtain the sum of all the elements.AlgorithmStep 1: Import numpy. Step 2: Create a random m×n matrix ... Read More

How to find the first date of a given year using Python?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:22:19

4K+ Views

In this program, we have to print the first day of the year. We have to take a year as a user input.AlgorithmStep 1: Import the datetime library. Step 2: Take year as input from the user. Step 3: Get the first day of the year by passing month, day ... Read More

How to create a numpy array within a given range?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:21:08

1K+ Views

We have to create a numpy array in the range provided by the user. We will use the arange() function in the numpy library to get our output.AlgorithmStep1: Import numpy. Step 2: Take start_value, end_value and Step from the user. Step 3: Print the array using arange() function in numpy.Example ... Read More

How to create an identity matrix using Numpy?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:20:45

4K+ Views

In this program, we will print an identity matrix of size nxn where n will be taken as an input from the user. We shall use the identity() function in the numpy library which takes in the dimension and the data type of the elements as parametersAlgorithmStep 1: Import numpy. ... Read More

Finding the number of rows and columns in a given matrix using Numpy

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:20:19

3K+ Views

We will first create a numpy matrix and then find out the number of rows and columns in that matrixAlgorithmStep 1: Create a numpy matrix of random numbers. Step 2: Find the rows and columns of the matrix using numpy.shape function. Step 3: Print the number of rows and columns.Example ... Read More

Write a Python program to remove a certain length substring from a given string

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:17:50

95 Views

We need to write a Python program which will remove a certain substring from a given stringAlgorithmStep 1: Define a string. Step 2: Use the replace function to remove the substring from the given string.Example CodeLive Demooriginal_string = "C++ is a object oriented programming language"modified_string = original_string.replace("object oriented", "")print(modified_string)OutputC++ is ... Read More

How to plot two dotted lines and set marker using Matplotlib?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:15:42

1K+ Views

In this program, we will plot two lines using the matplot library. Before starting to code, we need to first import the matplotlib library using the following command −Import matplotlib.pyplot as pltPyplot is a collection of command style functions that make matplotlib work like MATLAB.AlgorithmStep 1: Import matplotlib.pyplot Step 2: ... Read More

Advertisements