We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 10
ih
Home » Python
Python NumPy MCQs
Numpy is a Python package that is used to manipulate arrays of data. NumPy is an
abbreviation for Numerical Python. It also includes functions for working in the areas of linear
algebra, the Fourier transform, and matrices, among other things. Array objects can be created
with NumPy are up to 50 times faster than regular Python lists. In NumPy, Ndarray is the name
given to the array object.
Python NumPy MCQs: This section contains multiple-choice questions and answers on Python
Numby. These MCQs are written for beginners as well as advanced, practice these MCQs to
enhance and test the knowledge of Python NumPy.
List of Python NumPy MCQs
1. What is the purpose of NumPy in Python?
A. To do numerical calculations
B. To do scientific computing
C. Both A and B
D. None of the mentioned above
Answer: C) Both A and B
Explanation:
Numby is an abbreviation for ‘Numerical Python.’ NumPy is a Python library that allows users to
perform mathematical and logical operations on arrays. As a result, NumPy is considered a
Python package. There are multidimensional array objects and a collection of routines for
processing the arrays in this library, which may be found here. NumPy consists of
multidimensional array objects as well as a collection of procedures for manipulating and
processing those arrays.
Discuss this Question )2. NumPy package is capable to do fast operations on arrays.
A. True
B. False
Answer: A) True
Explanation:
NumPy package is capable to do fast operations on arrays including mathematical, logical,
shape manipulation, sorting, selecting, /O, discrete Fourier transforms, basic linear algebra,
basic statistical operations, random simulation and much more.
r )
Discuss this Question }
3. Amongst which Python library is similar to Pandas?
A.NPy
B. RPy
c. Numpy
D. None of the mentioned above
Answer: C) NumPy
Explanation:
Like NumPy, Pandas is one of the most extensively used python libraries in data science, and it
is similar to NumPy. Data structures and analytical tools that are high-performance and simple
to use are provided by the system. The Pandas library, in contrast to the NumPy library, which
provides objects for multi-dimensional arrays, provides an in-memory two-dimensional table
object called DataFrame.
Discuss this Question )
\ )
4, Amongst which of the following is true with reference to Pip in Python?
A. Pip is a standard package management system
B. Itis used to install and manage the software packages written in Python
C. Pip can be used to search a Python package
D. All of the mentioned aboveAnswer: D) All of the mentioned above
Explanation:
Pip is a standard package management system that is used to install and manage software
packages that are written in the Python programming language.
Discuss this Question )
5. NumPy arrays can be_.
A. Indexed
B. Sliced
C Iterated
D. All of the mentioned above
Answer: D) All of the mentioned above
Explanation:
The index value of an array starts at zero, and each element is referred by the index value of
the previous member.
Discover related topics
Mcq Questions and Answers
Best Python Distribution for Data Science
Python Matrix Assignment
Numpy for Data Science
Numpy Data Analysis
Slicing - Slicing is used when we need to extract a portion of an array from another. This is
accomplished by the use of slicing. We can indicate which part of the array should be sliced byusing the [start: end] syntax in conjunction with the array name to give the start and end index
values.
Iterating - The first axis of a multidimensional array is used to iterate through the arrays, for
example.
for x in b:
print (x)
Discuss this Question )
6. Observe the following code and identify what will be the outcome?
Copy
import numpy as np
acnp.array([1,2,3,4,5,6])
print(a)
A.(12345]
B.[123456]
€.[0123456]
D. None of the mentioned above
Answer: B) [12345 6]
Explanation:
In the above code, an array of six elements declared and assign it to the variable a. In the next
line of code, ais printing. So, all the elements which are in array a will be print on screen,
Discuss this Question )
\ )
7. Observe the following code and identify what will be the outcome?
Copy
import numpy as npx = np.array([[@, 1],
(2, 3]])
np. transpose(x)
A. array([[@, 21,
(1, 3]])
B. array([[@, 21],
[2, 3]])
C. array([[2, 3],
[e, 1]])
D. None of the mentioned above
Answer: A)
array([[@, 2],
2, 3]])
Explanatio!
In the above code, an array has been declared and stored in a variable x. And then, matrix
transposed and print.
Discuss this Question )
8. Observe the following code and identify what will be the outcome?
Copy
import numpy as np
a= np.array([[ ®, 1, 2, 3],
(4, 5, 6 7],
[8 9, 10, 11)])
A. True
B. False
Answer: A) TrueExplanation:
In the above code, the matrix has assigned to the variable a and then copy it to the variable 6.
Hence, when we will run the code it will print true ie Boolean value.
Discuss this Question )
9. The ix_ function can be used to combine different vectors.
A. True
B. False
Answer: A) True
Explanation:
To acquire the result for each n-uplet, the ix_ function can be used to mix different vectors
together in one operation.
Discuss this Question )
10. Observe the following code and identify what will be the outcome?
Copy
import numpy as np
a = np.array([10, 20, 30, 40])
b = np.array([18, 15, 14])
¢ = np.array([25, 24, 26, 28, 23])
x, y, 2 = np.ix(a, by c)
print (x)
A. [[[1e]]
([20]]
((30]]
([4e]]]c (f181]
((15]]
((14]]]
D. None of the mentioned above
‘Answer: A)
(([10]]
[[2e]]
((3¢}}
[140] ]}
Explanation:
To acquire the result for each n-uplet, the ix_ function can be used to mix different vectors
together in one operation. In this case, if you wish to compute all of the a+b*c for all of the
triplets derived from each of the vectors a, b, and c.
cr \
Discuss this Question )
11. What will be the output of the following Python code?
Copy
from numpy import randomx = random. randint (100)
print (x)
A.S6
B. 26
c.40
D. All of the mentioned above
Answer: D) All of the mentioned above
Explanation:
In the above code, random.randint(1@0) function has been used which is used to create any
integer number till 100.
ee F
Discuss this Question )
12. Binomial Distribution is a Discrete Distribution.
A. True
B. False
Answer: A) True
Explanation:
A Discrete Distribution is the same as a Binomial Distribution. If you toss a coin, the outcome
will be either heads or tails. This term explains the outcome of binary circumstances. It is
comprised of three parameters
* 1n-is the number of tries.
* p- denotes the likelihood that each trial will occur (e.g. for toss of a coin 0.5 each).
* size - The size of the array that was returned.
Discuss this Question )
13, Using ndim we can find -
A. We can find the dimension of the arrayB. Size of array
C. Operational activities on Matrix
D. None of the mentioned above
Answer: A) We can find the dimension of the array
Explanation:
We can determine the dimension of an array, regardless of whether it is a two-dimensional
array or a single-dimensional array.
Discuss this Question )
\
14. Observe the code and identify the outcome:
Copy
from numpy import random
x = random.binomial(n=108, p=0.5, size=10)
print (x)
A. [41 53 50 52 60 47 50 50 50 46]
B. [50 52 60 47 50 50 50 46]
C. [41 53 50 52 60 47 50]
D. None of the mentioned above
Answer: A) [41 53 50 52 60 47 50 50 50 46]
Explanation:
In the above code, binomial distribution has been used so the outcome of the code will be [41
53 50 52 60 47 50 50 50 46].
>
Discuss this Question )
15. What will be the output of following Python code?
Copyimport numpy as np
a = np.array([(10,20,3@)])
print(a.itemsize)
A.10
B.9
C8
D. All of the mentioned above
Answer: C) 8
Explanation:
Using itemsize, we can determine the byte size of each element. In the above code, a single-
dimensional array has built, and we can determine the size of each element with the aid of the
itemsize function
=
Discuss this Question )
\
Related MCQs
Python Variables MCQs
Python Pandas MCQs
Python SciPy MCQs
Python List MCQs
Python Tuples MCQs
Python Dictionary MCQs
Python PyQt MCQs
Django MCQs
Matplotlib MCQs
Learn & Test Your Skills