Skip to main content
Chapter 6 of 8
NCERT Solutions

Introduction to Numpy — NCERT Solutions

CBSE · Class 11 · Informatics Practices

NCERT Solutions for Introduction to Numpy, CBSE Class 11 Informatics Practices: 50 textbook questions solved step by step. Covers Exercise.

125 questions80 flashcards6 formulas & key relations5 concepts

Interactive on Super Tutor

Studying Introduction to Numpy? Get the full interactive chapter.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for NCERT solutions and more.

Free trial, no card needed.

50 Questions Solved · 1 Section

The first 25 solutions are open to read. The other 25 are free with a Super Tutor account. Unlock all 50 free in Super Tutor

Exercise

1What is NumPy ? How to install it?Show solution

NumPy stands for Numerical Python. It is a Python package used for data analysis and scientific computing. It uses a multidimensional array object and provides tools for working with arrays. To install it, type:

pip install NumPy

Not sure why a step works? check your working in Super Tutor

2What is an array and how is it different from a list? What is the name of the built-in array class in NumPy ?Show solution

An array is a data type used to store multiple values using a single identifier. Its elements are of the same data type, are stored contiguously in memory, and are accessed by index.

A list in Python can contain elements of different data types, is not stored contiguously in memory, and does not support element-wise operations like arrays do.

The built-in array class in NumPy is called ndarray.

Not sure why a step works? check your working in Super Tutor

3What do you understand by rank of an ndarray?Show solution

The rank of an ndarray means the number of dimensions or axes in the array. For example, a 1-D array has rank 1 and a 2-D array has rank 2.

Not sure why a step works? check your working in Super Tutor

4(a)A 1-D array called zeros having 10 elements and all the elements are set to zero.

Create the following NumPy arrays:

Show solution

Use np.zeros() to create a 1-D array of 10 zeros:

zeros = np.zeros(10)

This creates an array with 10 elements, all set to 0.

Not sure why a step works? check your working in Super Tutor

4(b)A 1-D array called vowels having the elements 'a', 'e', 'i', 'o' and 'u'.

Create the following NumPy arrays:

Show solution

Create the 1-D array using np.array() with the given vowels:

vowels = np.array(['a', 'e', 'i', 'o', 'u'])

Not sure why a step works? check your working in Super Tutor

4(c)A 2-D array called ones having 2 rows and 5 columns and all the elements are set to 1 and dtype as int.

Create the following NumPy arrays:

Show solution

Create a 2-D array with 2 rows and 5 columns using np.ones() and set dtype=int:

ones = np.ones((2, 5), dtype=int)

Not sure why a step works? check your working in Super Tutor

4(d)Use nested Python lists to create a 2-D array called myarray1 having 3 rows and 3 columns and store the following data:
2.7, -2, -19
0, 3.4, 99.9
10.6, 0, 13
Show solution

Use nested lists inside np.array():

np.array([[2.7, -2, -19], [0, 3.4, 99.9], [10.6, 0, 13]])

Not sure why a step works? check your working in Super Tutor

4(e)A 2-D array called myarray2 using arange() having 3 rows and 5 columns with start value = 4, step size 4 and dtype as float.

Create the following NumPy arrays:

Show solution

Use np.arange() with start value 4 and step size 4, then reshape it into 3 rows and 5 columns. Since 3 × 5 = 15, we need 15 elements: 4, 8, 12, ... , 60.

myarray2 = np.arange(4, 64, 4, dtype=float).reshape(3, 5)

This creates:

array([[ 4.,  8., 12., 16., 20.],
       [24., 28., 32., 36., 40.],
       [44., 48., 52., 56., 60.]])

Not sure why a step works? check your working in Super Tutor

5(a)Find the dimensions, shape, size, data type of the items and itemsize of arrays zeros, vowels, ones, myarray1 and myarray2.Show solution

Use these commands:

  • zeros: zeros.ndim, zeros.shape, zeros.size, zeros.dtype, zeros.itemsize
  • vowels: vowels.ndim, vowels.shape, vowels.size, vowels.dtype, vowels.itemsize
  • ones: ones.ndim, ones.shape, ones.size, ones.dtype, ones.itemsize
  • myarray1: myarray1.ndim, myarray1.shape, myarray1.size, myarray1.dtype, myarray1.itemsize
  • myarray2: myarray2.ndim, myarray2.shape, myarray2.size, myarray2.dtype, myarray2.itemsize

These give the dimensions, shape, size, data type, and itemsize of each array.

Not sure why a step works? check your working in Super Tutor

5(b)Reshape the array ones to have all the 10 elements in a single row.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

Reshape ones into a single row with 10 elements:

ones.reshape(1, 10)

Not sure why a step works? check your working in Super Tutor

5(c)Display the 2nd and 3rd element of the array vowels.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

Use slicing from index 1 to 3, because Python indexing starts at 0 and the end index is excluded:

vowels[1:3]

Not sure why a step works? check your working in Super Tutor

5(d)Display all elements in the 2nd and 3rd row of the array myarray1.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

To display all elements in the 2nd and 3rd rows, slice rows 1 to 3 and take all columns:

myarray1[1:3, :]

Not sure why a step works? check your working in Super Tutor

5(e)Display the elements in the 1st and 2nd column of the array myarray1.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

To display the elements in the 1st and 2nd columns of myarray1, select all rows and columns 0 to 2:

myarray1[:, 0:2]

Not sure why a step works? check your working in Super Tutor

5(f)Display the elements in the 1st column of the 2nd and 3rd row of the array myarray1.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

To display the elements in the 1st column of the 2nd and 3rd row, choose rows 1 to 3 and column 0:

myarray1[1:3, 0]

Not sure why a step works? check your working in Super Tutor

5(g)Reverse the array of vowels.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

Reverse the 1-D array using slicing with step -1:

vowels[::-1]

Not sure why a step works? check your working in Super Tutor

6(a)Divide all elements of array ones by 3.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

Use element-wise division by 3:

ones / 3

If you want to store it back in the same array:

ones = ones / 3

Not sure why a step works? check your working in Super Tutor

6(b)Add the arrays myarray1 and myarray2.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

Add the two arrays element-wise:

myarray1 + myarray2

Not sure why a step works? check your working in Super Tutor

6(c)Subtract myarray1 from myarray2 and store the result in a new array.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

Subtract myarray1 from myarray2 and save the result in a new array:

result = myarray2 - myarray1

Not sure why a step works? check your working in Super Tutor

6(d)Multiply myarray1 and myarray2 elementwise.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

Element-wise multiplication is:

myarray1 * myarray2

Not sure why a step works? check your working in Super Tutor

6(e)Do the matrix multiplication of myarray1 and myarray2 and store the result in a new array myarray3.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

Matrix multiplication uses the @ operator. Store the result in myarray3:

myarray3 = myarray1 @ myarray2

Not sure why a step works? check your working in Super Tutor

6(f)Divide myarray1 by myarray2.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

Divide myarray1 by myarray2 element-wise:

myarray1 / myarray2

Not sure why a step works? check your working in Super Tutor

6(g)Find the cube of all elements of myarray1 and divide the resulting array by 2.Show solution

First cube every element using ** 3, then divide the resulting array by 2:

(myarray1 ** 3) / 2

Not sure why a step works? check your working in Super Tutor

6(h)Find the square root of all elements of myarray2 and divide the resulting array by 2. The result should be rounded to two places of decimals.Show solution

Take the square root of each element of myarray2, divide by 2, then round to two decimal places:

np.round(np.sqrt(myarray2) / 2, 2)

Not sure why a step works? check your working in Super Tutor

7(a)Find the transpose of ones and myarray2.Show solution

The transpose of an array is obtained using transpose():

ones.transpose()
myarray2.transpose()

Not sure why a step works? check your working in Super Tutor

7(b)Sort the array vowels in reverse.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Show solution

To sort the array in reverse order, use sort() and then reverse the array:

vowels.sort()
vowels[::-1]

Or directly print the reversed sorted array after sorting.

Not sure why a step works? check your working in Super Tutor

7(c)Sort the array myarray1 such that it brings the lowest value of the column in the first row and so on.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Free with a Super Tutor account

8(a)Use NumPy.split() to split the array myarray2 into 5 arrays columnwise. Store your resulting arrays in myarray2A, myarray2B, myarray2C, myarray2D and myarray2E. Print the arrays myarray2A, myarray2B, myarray2C, myarray2D and myarray2E.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Free with a Super Tutor account

8(b)Split the array zeros at array index 2, 5, 7, 8 and store the resulting arrays in zerosA, zerosB, zerosC and zerosD and print them.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Free with a Super Tutor account

8(c)Concatenate the arrays myarray2A, myarray2B and myarray2C into an array having 3 rows and 3 columns.

Using the arrays created in Question 4 above, write NumPy commands for the following:

Free with a Super Tutor account

9Create a 2-D array called myarray4 using arange() having 14 rows and 3 columns with start value = -1, step size 0.25 having. Split this array row wise into 3 equal parts and print the result.

Free with a Super Tutor account

10(a)Find the sum of all elements.

Using the myarray4 created in the above questions, write commands for the following:

Free with a Super Tutor account

10(b)Find the sum of all elements row wise.

Using the myarray4 created in the above questions, write commands for the following:

Free with a Super Tutor account

10(c)Find the sum of all elements column wise.

Using the myarray4 created in the above questions, write commands for the following:

Free with a Super Tutor account

10(d)Find the max of all elements.

Using the myarray4 created in the above questions, write commands for the following:

Free with a Super Tutor account

10(e)Find the min of all elements in each row.

Using the myarray4 created in the above questions, write commands for the following:

Free with a Super Tutor account

10(f)Find the mean of all elements in each row.

Using the myarray4 created in the above questions, write commands for the following:

Free with a Super Tutor account

10(g)Find the standard deviation column wise.

Using the myarray4 created in the above questions, write commands for the following:

Free with a Super Tutor account

1Load the data in the file Iris.txt in a 2-D array called iris.

Free with a Super Tutor account

2Drop column whose index = 4 from the array iris.

Free with a Super Tutor account

3Display the shape, dimensions and size of iris.

Free with a Super Tutor account

4Split iris into three 2-D arrays, each array for a different species. Call them iris1, iris2, iris3.

Free with a Super Tutor account

6Create a 1-D array header having elements "sepal length", "sepal width", "petal length", "petal width", "Species No" in that order.

Free with a Super Tutor account

8Find the max, min, mean and standard deviation for the columns of the iris and store the results in the arrays iris_max, iris_min, iris_avg, iris_std, iris_var respectively. The results must be rounded to not more than two decimal places.

Free with a Super Tutor account

9Similarly find the max, min, mean and standard deviation for the columns of the iris1, iris2 and iris3 and store the results in the arrays with appropriate names.

Free with a Super Tutor account

10Check the minimum value for sepal length, sepal width, petal length and petal width of the three species in comparison to the minimum value of sepal length, sepal width, petal length and petal width for the data set as a whole and fill the table below with True if the species value is greater than the dataset value and False otherwise.
Iris setosaIris virginicaIris versicolor
sepal length
sepal width
petal length
petal width

Free with a Super Tutor account

11Compare Iris setosa's average sepal width to that of Iris virginica.

Free with a Super Tutor account

12Compare Iris setosa's average petal length to that of Iris virginica.

Free with a Super Tutor account

13Compare Iris setosa's average petal width to that of Iris virginica.

Free with a Super Tutor account

14Save the array iris_avg in a comma separated file named IrisMeanValues.txt on the hard disk.

Free with a Super Tutor account

15Save the arrays iris_max, iris_avg, iris_min in a comma separated file named IrisStat.txt on the hard disk.

Free with a Super Tutor account

25 more solved questions in Introduction to Numpy

They are free with a Super Tutor account, along with practice quizzes and flashcards for this chapter. Free to start, no card needed.

Frequently Asked Questions

What are the important topics in Introduction to Numpy for CBSE Class 11 Informatics Practices?
Key topics in Introduction to Numpy include NumPy and Arrays, Creating NumPy Arrays, Indexing and Slicing, Operations on Arrays. Study these first, then practise questions on each for Class 11 exams.
Are these NCERT Solutions for Introduction to Numpy free?
The first 25 of the 50 solutions on this page are open to read. The other 25 are free with a Super Tutor account — signing up is free and needs no card.
How should I revise Introduction to Numpy for Class 11 exams?
Learn the core ideas first, then work through the 125 practice questions on Introduction to Numpy. Revise definitions regularly and use flashcards for quick recall before the exam.

Sources & Official References

Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.

For serious students

Get the full Introduction to Numpy chapter — start free.

Quizzes, flashcards, an AI doubt solver and a study plan for CBSE Class 11 Informatics Practices. Free to start, no card needed.