Numpy in Practice.

Subham Singh
3 min readDec 26, 2019

I am back again with some good practice questions on Numpy. Link for the previous practice exercise is given at the end. Just follow along and within a couple of days, you would be adding a new skill within your skills set and would be more comfortable while playing with numeric data using numpy.

This is the second part of Numpy in Practice series.

So without taking more time, here we start..

Do not forget to import numpy as np before running the codes.

  1. Creating a 3x3x3 matrix with random values.
Do not forget to pass the shape of a matrix within parentheses.

2. Finding maximum and minimum from an array.

3. Finding the mean value of a vector or a matrix.

4. Creating a 2D array with one on the border and zeros inside.

Let’s have a look at some of the interesting results.

But, before that a little titbit about NaN.

  • NaN stands for not a number.
  • Commonly used for representing missing data.

Above output is just because two nan objects can never be equal. Think like that one NaN would have been created because of some failure and other NaN would be
due to some other failure, so two diff objects can never be equal. Take it as intuition.

Above the result is because python first checks identity, not equality

I am leaving here, some the results without explanation so that you can search about that, in the field of data believe or not you are literally going to search about the codes, results, etc more, than writing the codes for predictive modelling, algorithm, etc in your learning phase. So just search about it on StackOverflow, Quora, documentation, etc. and enhance your self-learning skills. I have used Jupyter notebook to run these codes.

Click on This for Previous practice questions.

Link for the Next part would be available here soon.

--

--

Subham Singh

Data Science, Machine Learning and Deep Learning practitioner. Always ready to learn and lead. Linkedin username “subham121singh”