Chapter 6: Introduction to NumPy


NCERT solutions Introduction to NumPy

1. What is NumPy ? How to install it?

Numpy stands for Numberical Python . It is a package for data analysis and scientific computing with Python.
Numpy can be installed by typing the commond : pip install Numpy 


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

Array is a data type used to store multiple values using a single identifier (variable name ) . An array constains an ordered collection of data elements where each element is of the same type and can be referenced by its index ( position )
ndarray is the name of the built-in array class in Numpy .


3. What do you understand by rank of an ndarray?

The number of dimensions or axes of the array is called rank of the array.


4. Create the following NumPy arrays:

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

zeros = np.zeros((1,10))


b) A 1-D array called vowels having the elements ‘a’,‘e’, ‘i’, ‘o’ and ‘u’

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


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.

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


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

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


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.

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



NCERT solutions Introduction to NumPy


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

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

zeros.shape
vowels.shape
ones.shape
myarray1.shape
myarray2.shape

zeros.size
vowels.size
ones.size
myarray1.size
myarray2.size

zeros.dtype
vowels.dtype
ones.dtype
myarray1.dtype
myarray2.dtype

zeros.itemsize
vowels.itemsize
ones.itemsize
myarray1.itemsize
myarray2.itemsize


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

ones.reshape(1,10)


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

print(vowal[1],vowel[2])


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

print(myarray1[1:3,])


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

print(myarray1[0:3,0:2])


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

print((myarray1[1:3,0:3]).reshape(1,6))


g) Reverse the array of vowels.

print(vowal[::-1]


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

a) Divide all elements of array ones by 3. 

ones/1


b) Add the arrays myarray1 and myarray2.

myarray1 + myarray2


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

newarray = myarray2 – myarray1


d) Multiply myarray1 and myarray2 elementwise.

myarray1 * myarray2


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

myarray3 = myarray1 @ myarray2


f) Divide myarray1 by myarray2.

myarray1 / myarray2


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

myarray1 **3/2


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.

np.around(myarray**(1/2)/2,2)


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

a) Find the transpose of ones and myarray2.

ones.transpose()
myarray2.transpose


b) Sort the array vowels in reverse.

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


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

myarray1.sort(axis=0)


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

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.



myarray2A, myarray2B, myarray2C, myarray2D, myarray2E = np.array_split(myarray2,5,axis=1)


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

(np.array([myarray2A, myarray2B, myarray2C])).reshape(3,3)


9. Create 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.

myarray4 = np.arrange(-1,9.5,0.25)
a1,a2,a3 = np.array_split(myarray4,3,axis=0)



NCERT solutions Introduction to NumPy


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

a) Find the sum of all elements.

myarray4.sum()


b) Find the sum of all elements row wise.

myarray4.sum(axis=1)


c) Find the sum of all elements column wise.

myarray4.sum(aixis=0)


d) Find the max of all elements.

myarray4.max()


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

myarray4.min()


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

myarray4.mean(axis=1)


g) Find the standard deviation column wise.

myarray4..std(axis=0)




NCERT Class 11 Solutions can be of great value if you are trying to excel in your school examinations. The journey starts directly from when you step into class 1 as every class holds great to use as you progress. CBSE Class 11 is no doubt a very valuable class and the last class of your school life. Not to mention, it also leads to a lot of career-making decisions as you seem for some important competitive exams to get your desire college. NCERT solution can help you immensely throughout this adventure of yours.

NCERT Class 11 Solutions

Although higher classes students like Class 10-12 should have a better knowledge of all the topics that will help them to examine deeper into the basics as well as an advanced level of questions that are asked in many competitive exams after 12 class. One of the best ways to achieve it is by answering questions of NCERT Books with the help of NCERT solutions. We at SelfStudys strive hard to devise better ideas in order to help students and give you detailed solutions for all questions from the NCERT textbook as per the latest CBSE CCE marking scheme pattern is to back you up in useful learning in all the exams conducted by CBSE curriculum. The plethora of advantages of referring to NCERT solutions requires an in-depth understanding of detailed solutions of all NCERT book’s questions.


We have given all the detailed NCERT questions and solutions in PDF format which you can read for FREE. All you have to do is download the SelfStudys NCERT Solutions for Class 11 once for FREE and you are able to go. You can get all the Subject NCERT solutions by the links provided here. NCERT Solutions for all the subjects of Class 11 is available on this page including NCERT Class 11 Solution for Maths, Chemistry, Physics, English, Business Studies, Biology, economics are provided below to download in a free PDF file.



NCERT Solution for Class 11

NCERT Class 11 Solutions to the questions with Chapter-wise, detailed are given with the objective of helping students compare their answers with the example. NCERT books provide a strong foundation for every chapter. They ensure a smooth and easy knowledge of advanced concepts. As suggested by the HRD ministry, they will perform a major role in JEE.



NCERT Class 11 Solutions | NCERT Solution for Class 11

NCERT Solution for Class 11 includes all the questions given in NCERT Books for all Subjects. Here all questions are solved with detailed information and available for free to check. NCERT Solutions for Class 11 are given here for all chapter-wise. Select the subject and choose a chapter to view NCERT Solution chapter-wise. We hope that our NCERT Class 11 Solutions helped with your studies! If you liked our NCERT Solutions for Class 11, please share this post.



Why NCERT Solutions for Class 11 is Important?

NCERT Class 11 Solutions increases the base for conceptual knowledge. It provides a complete view of the prescribed syllabus, as the textbook doesn't have a detailed description of the syllabus nor solutions. All the important theorems and formulas of Class 11 are completely solved, which works to make the concepts and find new links to them. Importantly, the NCERT Class 11 Solutions is the point of reference for those students planning for competitive examinations such as NRRT, JEE Main/Advanced, BITSAT & VITEEE, etc. When the NCERT book is accompanied by the solutions, the knowledge of concepts becomes simple and in-depth. Moreover, students can trail into the solutions without break in topics, as it is designed to give a step-by-step explanation. Try out the Class 11 Solutions and learn from the resources.



Why try NCERT Class 11 Solutions?

Well, here are the solid reasons why you should and must try out the NCERT Class 11 Solutions.

Has ERRORLESS answers with 100% Reasoning

The quality of solutions is perfect

Gives in-depth knowledge with notes shortly after the solutions with shortcuts, tips, alternative methods & points to remember

Gives quick revision of the concepts included along with important definitions and Formulas on the chapters, which acts as a prepared refresher.

Designed step-by-step to give 100% Concept Clearness



No comments:

Post a Comment

Have query? Just say it.