Introduction to NumPy

Introduction to NumPy


NumPy (“Numerical Python” or Numeric Python”) is an open source module of Python that provides functions for fast mathematical computation on arrays and matrices.

To use NumPy, it is needed to import. Syntax for that is:

>>>import numpy as np

here np, is an alias for numpy which is optional

NumPy arrays come in two forms:

  • 1-D array – also known as Vectors.
  • Multidimensional arrays – Also known as Matrices.
Qus. 1 : NumPY stands for?

  1. Numbering Python
  2. Number in Python
  3. Numerical Python
  4. Number for Python
Qus. 2 : NumPy arrays can be

  1. Indexed
  2. Sliced
  3. Iterated
  4. All of the mentioned above
Qus. 3 : Using ndim we can find

  1. We can find the dimension of the array
  2. Size of array
  3. Operational activities on Matrix
  4. None of the mentioned above
Qus. 4 : Numpy developed by?

  1. Guido van Rossum
  2. Travis Oliphant
  3. Wes McKinney
  4. Jim Hugunin
Qus. 5 : Which of the following Numpy operation are correct?

  1. Mathematical and logical operations on arrays.
  2. Fourier transforms and routines for shape manipulation.
  3. Operations related to linear algebra.
  4. All of the above
Qus. 6 : What is a correct syntax to create a NumPy array?

  1. np.array([4,5,6])
  2. np.create_array([4,5,6])
  3. np.createArray([4,5,6])
  4. np.numpyArray([4,5,6])
Qus. 7 : How to import numpy module?

  1. from numpy import *
  2. import numpy
  3. import numpy as my_numpy
  4. All of above
Qus. 8 : Attribute of array determines

  1. Size, shape
  2. memory consumption
  3. data type of array
  4. All of these
Qus. 9 : Getting and setting the value of individual array elements:

  1. Indexing
  2. Slicing
  3. Reshaping
  4. None of the above
Qus. 10 : Getting and setting smaller subarrays within a larger array

  1. Indexing
  2. Slicing
  3. Reshaping
  4. None of the above
Qus. 11 : The number of axes in an ndarray is called its ___

  1. rank
  2. dtype
  3. shape
  4. None of these
Qus. 12 : NumPy arrays used over lists because

  1. NumPy arrays have contiguous memory location
  2. They are more speedy to work with
  3. They are more convenient to deal with
  4. All of the above
Qus. 13 : <p>What will be output for the following code ?</p><pre>import numpy as np<br>a=np.array([2,3,4,5])<br>print(a.dtype)</pre><div><br></div>

  1. int32
  2. int
  3. float
  4. none of these
Qus. 14 : What is the use of the zeros() function in Numpy array in python ?

  1. To make a Matrix with all element 0
  2. To make a Matrix with all diagonal element 0
  3. To make a Matrix with first row 0
  4. None of the above
Qus. 15 : NumPY stands for:

  1. Numbering Python
  2. Number In Python
  3. Numerical Python
  4. None of the above
Qus. 16 : <p>What will be output for the following code ?</p><p><span style="font-size: 14px;">import numpy as np</span></p><p><span style="font-size: 14px;">ary=np.array([1,2,3,5,8])</span></p><p><span style="font-size: 14px;">ary=ary+1</span></p><p><span style="font-size: 14px;">print(ary[1])</span></p><div><br></div>

  1. 0
  2. 1
  3. 2
  4. 3
Qus. 17 : What is NumPy?

  1. A machine learning library
  2. A web development framework
  3. A numerical computing library in Python
  4. A data visualization tool
Qus. 18 : Which of the following is the primary object in NumPy for representing arrays?

  1. Array
  2. List
  3. Matrix
  4. Tuple
Qus. 19 : What is the purpose of the np.array() function in NumPy?

  1. It creates a new Python list.
  2. It creates a NumPy array.
  3. It performs element-wise addition.
  4. It calculates the mean of an array.
Qus. 20 : What is the primary purpose of NumPy in Python?

  1. Web development
  2. Machine learning and scientific computing
  3. Game development
  4. Database management

Programs

Create a numpy array having two dimensions and shape(3,3) and perform the following operations on array elements:

View Solution


Write a program to find the intersection of two arrays

View Solution


CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad