\[
\textbf{Difficult MCQs on Python for Scientific Computing with Answers}
\]
\[
\textbf{Q1: Which of the following is the correct method to generate a random number between 0 and 1 using NumPy?}
\]
\[
\text{(A) } \text{random() } \text{from random module}
\]
\[
\text{(B) } \text{np.random.random()}
\]
\[
\text{(C) } \text{np.random.uniform(0, 1)}
\]
\[
\text{(D) } \text{random.randint(0, 1)}
\]
\[
\textbf{Answer: (B) np.random.random()}
\]
\[
\textbf{Q2: What does the function \texttt{scipy.integrate.quad()} perform in Python?}
\]
\[
\text{(A) } \text{Solves linear equations}
\]
\[
\text{(B) } \text{Computes numerical integration of a function}
\]
\[
\text{(C) } \text{Finds the determinant of a matrix}
\]
\[
\text{(D) } \text{Computes the eigenvalues of a matrix}
\]
\[
\textbf{Answer: (B) Computes numerical integration of a function}
\]
\[
\textbf{Q3: Which of the following methods can be used to solve a system of linear equations \texttt{Ax = b} in Python?}
\]
\[
\text{(A) } \text{np.linalg.solve(A, b)}
\]
\[
\text{(B) } \text{np.linalg.inv(A) @ b}
\]
\[
\text{(C) } \text{scipy.linalg.solve(A, b)}
\]
\[
\text{(D) } \text{All of the above}
\]
\[
\textbf{Answer: (D) All of the above}
\]
\[
\textbf{Q4: What is the output of the following Python code?}
\]
\[
\texttt{import numpy as np \newline x = np.array([1, 2, 3]) \newline print(x ** 2)}
\]
\[
\text{(A) } \text{[1, 4, 9]}
\]
\[
\text{(B) } \text{[2, 4, 6]}
\]
\[
\text{(C) } \text{[1, 3, 5]}
\]
\[
\text{(D) } \text{[1, 4, 8]}
\]
\[
\textbf{Answer: (A) [1, 4, 9]}
\]
\[
\textbf{Q5: Which Python library is commonly used for symbolic mathematics and algebra?}
\]
\[
\text{(A) } \text{Matplotlib}
\]
\[
\text{(B) } \text{SymPy}
\]
\[
\text{(C) } \text{SciPy}
\]
\[
\text{(D) } \text{NumPy}
\]
\[
\textbf{Answer: (B) SymPy}
\]
\[
\textbf{Q6: Which of the following functions is used to create a mesh grid in Python for 3D plotting?}
\]
\[
\text{(A) } \text{np.meshgrid()}
\]
\[
\text{(B) } \text{np.linspace()}
\]
\[
\text{(C) } \text{np.random.rand()}
\]
\[
\text{(D) } \text{np.reshape()}
\]
\[
\textbf{Answer: (A) np.meshgrid()}
\]
\[
\textbf{Q7: What does the \texttt{scipy.optimize.minimize()} function do?}
\]
\[
\text{(A) } \text{Finds the local minimum of a function}
\]
\[
\text{(B) } \text{Finds the global maximum of a function}
\]
\[
\text{(C) } \text{Solves a linear optimization problem}
\]
\[
\text{(D) } \text{Computes the Fourier transform}
\]
\[
\textbf{Answer: (A) Finds the local minimum of a function}
\]
\[
\textbf{Q8: Which of the following statements is true about NumPy arrays compared to lists in Python?}
\]
\[
\text{(A) } \text{NumPy arrays can hold elements of different data types}
\]
\[
\text{(B) } \text{NumPy arrays are less efficient than Python lists}
\]
\[
\text{(C) } \text{NumPy arrays require less memory and are faster for numerical computations}
\]
\[
\text{(D) } \text{NumPy arrays are not capable of performing vectorized operations}
\]
\[
\textbf{Answer: (C) NumPy arrays require less memory and are faster for numerical computations}
\]
\[
\textbf{Q9: Which of the following functions from the NumPy library can be used to compute the determinant of a matrix?}
\]
\[
\text{(A) } \text{np.linalg.inv()}
\]
\[
\text{(B) } \text{np.linalg.det()}
\]
\[
\text{(C) } \text{np.linalg.eig()}
\]
\[
\text{(D) } \text{np.linalg.solve()}
\]
\[
\textbf{Answer: (B) np.linalg.det()}
\]
\[
\textbf{Q10: What is the result of running the following Python code?}
\]
\[
\texttt{import numpy as np \newline x = np.array([2, 3, 4]) \newline print(np.sum(x))}
\]
\[
\text{(A) } \text{9}
\]
\[
\text{(B) } \text{6}
\]
\[
\text{(C) } \text{12}
\]
\[
\text{(D) } \text{0}
\]
\[
\textbf{Answer: (A) 9}
\]