Data Science Questions and Answers – NumPy – 2

This set of Data Science online test focuses on “NumPy – 2”.

1. Which of the following sets the size of the buffer used in ufuncs?
a) bufsize(size)
b) setsize(size)
c) setbufsize(size)
d) all of the mentioned
View Answer

Answer: c
Explanation: Adjusting the size of the buffer may therefore alter the speed at which ufunc calculations of various sorts are completed.

2. Point out the wrong statement.
a) A universal function is a function that operates on ndarrays in an element-by-element fashion
b) In Numpy, universal functions are instances of the numpy.ufunction class
c) Many of the built-in functions are implemented in compiled C code
d) All of the mentioned
View Answer

Answer: b
Explanation: ufunc instances can also be produced using the frompyfunc factory function.

3. Which of the following attribute should be used while checking for type combination input and output?
a) .types
b) .type
c) .class
d) all of the mentioned
View Answer

Answer: a
Explanation: Universal functions in NumPy are flexible enough to have mixed type signatures.

4. Which of the following returns an array of ones with the same shape and type as a given array?
a) all_like
b) ones_like
c) one_alike
d) all of the mentioned
View Answer

Answer: b
Explanation: The optional output arguments of the function can be used to help you save memory for large calculations.

advertisement
advertisement

5. Point out the wrong statement.
a) Each universal function takes array inputs and produces array outputs
b) Broadcasting is used throughout NumPy to decide how to handle disparately shaped arrays
c) The output of the ufunc is necessarily an ndarray, if all input arguments are ndarrays
d) All of the mentioned
View Answer

Answer: c
Explanation: The output of the ufunc is not necessarily an ndarray, if all input arguments are not ndarrays.

6. Which of the following set the floating-point error callback function or log object?
a) setter
b) settercall
c) setterstack
d) all of the mentioned
View Answer

Answer: b
Explanation: seterr sets how floating-point errors are handled.

Note: Join free Sanfoundry classes at Telegram or Youtube

7. Some ufuncs can take output arguments.
a) True
b) False
View Answer

Answer: b
Explanation: All ufuncs can take output arguments. If necessary, output will be cast to the data-type of the provided output array.

8. ___________ decompose the elements of x into mantissa and twos exponent.
a) trunc
b) fmod
c) frexp
d) ldexp
View Answer

Answer: c
Explanation: fmod function return the element-wise remainder of division.

advertisement

9. Which of the following function take only single value as input?
a) iscomplex
b) minimum
c) fmin
d) all of the mentioned
View Answer

Answer: a
Explanation: iscomplex function returns a bool array, where true if input element is complex.

10. The array object returned by __array_prepare__ is passed to the ufunc for computation.
a) True
b) False
View Answer

Answer: a
Explanation: If the class has an __array_wrap__ method, the returned ndarray result will be passed to that method just before passing control back to the caller.

advertisement

Sanfoundry Global Education & Learning Series – Data Science.

Here’s the list of Best Books in Data Science.

To practice all areas of Data Science for online test, Here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.