MCQs on Python for Data Science
Section A: Mean, Median, Mode, Variance, Standard Deviation
1. The mean of a dataset is calculated by:
A) Middle value
B) Most frequent value
C) Sum of all values divided by number of values
D) Difference between max and min
Answer: C
2. The median is:
A) The average value
B) The middle value after sorting
C) The highest value
D) The most repeated value
Answer: B
3. Mode represents:
A) The average
B) The central value
C) The most frequently occurring value
D) The smallest value
Answer: C
4. Variance measures:
A) Central tendency
B) Spread of data
C) Frequency
D) Correlation
Answer: B
5. Standard deviation is:
A) Square of variance
B) Square root of variance
C) Half of variance
D) Double of variance
Answer: B
6. If all values in a dataset are the same, the standard deviation will be:
A) 1
B) Negative
C) 0
D) Undefined
Answer: C
7. Which Python library function calculates mean?
A) [Link]()
B) [Link]()
C) Both A and B
D) [Link]()
Answer: C
8. Which measure is least affected by outliers?
A) Mean
B) Median
C) Variance
D) Standard Deviation
Answer: B
Section B: NumPy
9. NumPy stands for:
A) Numerical Python
B) Number Python
C) Numeric Program
D) New Python
Answer: A
10. Which function is used to create a NumPy array?
A) [Link]()
B) [Link]()
C) [Link]()
D) [Link]()
Answer: B
11. The dimension of an array is obtained using:
A) shape
B) size
C) ndim
D) dim
Answer: C
12. Which attribute gives total number of elements?
A) shape
B) size
C) ndim
D) dtype
Answer: B
13. Universal functions in NumPy operate:
A) On single values only
B) Element-wise on arrays
C) On strings
D) On dictionaries
Answer: B
14. Which of the following is a universal function?
A) [Link]()
B) [Link]()
C) [Link]()
D) All of the above
Answer: D
15. Which function returns the maximum value?
A) [Link]()
B) [Link]()
C) [Link]()
D) [Link]()
Answer: A
16. Which function returns the index of maximum value?
A) [Link]()
B) [Link]()
C) [Link]()
D) [Link]()
Answer: B
17. Broadcasting allows:
A) Printing arrays
B) Operations between arrays of different shapes
C) Sorting arrays
D) Copying arrays
Answer: B
18. For broadcasting to work, dimensions must:
A) Be exactly equal
B) Be compatible
C) Be sorted
D) Be 1D
Answer: B
19. Fancy indexing allows:
A) Indexing using boolean or integer arrays
B) Indexing only with slices
C) Indexing strings
D) Indexing dictionaries
Answer: A
20. Boolean indexing is used to:
A) Sort arrays
B) Filter arrays
C) Add arrays
D) Multiply arrays
Answer: B
Section C: Pandas
21. Pandas primarily provides:
A) Series and DataFrame
B) Lists and Tuples
C) Arrays and Matrices
D) Dictionaries only
Answer: A
22. A Pandas Series is:
A) 2D labeled data
B) 1D labeled data
C) 3D data
D) Unlabeled data
Answer: B
23. A DataFrame is:
A) 1D data structure
B) 2D labeled data structure
C) 3D array
D) Tuple
Answer: B
24. Which function displays first 5 rows?
A) [Link]()
B) [Link]()
C) [Link]()
D) [Link]()
Answer: C
25. Which function provides summary statistics?
A) [Link]()
B) [Link]()
C) [Link]()
D) [Link]()
Answer: B
26. Arithmetic operations in Pandas are:
A) Label-based
B) Position-based only
C) Not allowed
D) Random
Answer: A
27. Missing values in Pandas are represented by:
A) None only
B) 0
C) NaN
D) Blank space
Answer: C
28. Which function removes missing values?
A) drop()
B) remove()
C) dropna()
D) fill()
Answer: C
29. Which function replaces missing values?
A) fillna()
B) replacena()
C) modify()
D) update()
Answer: A
30. isnull() function is used to:
A) Remove null values
B) Detect missing values
C) Replace null values
D) Sort null values
Answer: B