Practice Library
All MCQs
Browse exam-wise, subject-wise, and country-wise MCQs with explanations.
Easy
Choose an option to check your answer.
A.
To guarantee a perfect predictive model
B.
To hide unexpected observations
C.
To replace data collection entirely
D.
To understand data patterns, quality, and relationships before formal modeling
Show Answer
Correct Answer: D. To understand data patterns, quality, and relationships before formal modeling
Explanation:
EDA uses summaries and visualizations to reveal structure, anomalies, and possible relationships. Its findings guide cleaning, feature choices, and later modeling decisions.
Medium
Choose an option to check your answer.
A.
Selects rows whose age value is at least 18
B.
Sorts the DataFrame by age in descending order
C.
Replaces every age with 18
D.
Deletes the age column
Show Answer
Correct Answer: A. Selects rows whose age value is at least 18
Explanation:
The comparison creates a Boolean mask indicating which rows satisfy the condition. Using that mask inside brackets filters the DataFrame to matching rows.
Easy
Choose an option to check your answer.
A.
A missing or undefined value
B.
A guaranteed zero
C.
A categorical label
D.
A duplicated row
Show Answer
Correct Answer: A. A missing or undefined value
Explanation:
`NaN` is commonly used as a marker for unavailable or undefined numerical data. It must not automatically be treated as an observed zero.
Easy
Choose an option to check your answer.
A.
Set
B.
DataFrame
C.
Scalar
D.
Generator
Show Answer
Correct Answer: B. DataFrame
Explanation:
A DataFrame organizes data into labeled rows and columns. It is the primary pandas structure for working with datasets resembling tables.
Medium
Choose an option to check your answer.
A.
It can contain only text
B.
It prevents all numerical errors
C.
It automatically selects machine-learning models
D.
It supports efficient vectorized operations
Show Answer
Correct Answer: D. It supports efficient vectorized operations
Explanation:
Vectorization applies operations across entire arrays using optimized numerical routines. This is usually clearer and faster than element-by-element Python loops.
Medium
Choose an option to check your answer.
A.
For a small anonymous function used briefly, such as a sorting key
B.
For creating a database server
C.
For replacing every loop in Python
D.
For defining an entire large software system
Show Answer
Correct Answer: A. For a small anonymous function used briefly, such as a sorting key
Explanation:
A lambda provides a concise unnamed function consisting of a single expression. It is useful for simple temporary operations but not for complex multi-step logic.
Medium
Choose an option to check your answer.
A.
`sum`
B.
`round`
C.
`range`
D.
`zip`
Show Answer
Correct Answer: D. `zip`
Explanation:
`zip` combines elements from multiple iterables position by position. It can produce name-score pairs for parallel processing.
Medium
Choose an option to check your answer.
A.
`type`
B.
`enumerate`
C.
`sorted`
D.
`abs`
Show Answer
Correct Answer: B. `enumerate`
Explanation:
`enumerate` yields pairs containing an index and the corresponding item from an iterable. It avoids manually maintaining a separate counter.
Medium
Choose an option to check your answer.
A.
`square(range) = 5`
B.
`(x + 2 while x < 5)`
C.
`{x: 2 for x in range(5)}`
D.
`[x**2 for x in range(5)]`
Show Answer
Correct Answer: D. `[x**2 for x in range(5)]`
Explanation:
A list comprehension evaluates `x**2` for each value produced by `range(5)`. The result is a new list containing 0, 1, 4, 9, and 16.
Medium
Choose an option to check your answer.
A.
It automatically manages closing the file when the block ends
B.
It guarantees that the file contains no errors
C.
It converts all text into numbers
D.
It prevents any other program from reading the file forever
Show Answer
Correct Answer: A. It automatically manages closing the file when the block ends
Explanation:
A context manager handles resource cleanup even when an error occurs inside the block. This reduces the risk of leaving the file open unintentionally.
Medium
Choose an option to check your answer.
A.
`for` and `in`
B.
`import` and `as`
C.
`def` and `return`
D.
`try` and `except`
Show Answer
Correct Answer: D. `try` and `except`
Explanation:
Code that may fail is placed in a `try` block, and matching errors can be handled in `except` blocks. This supports controlled recovery from expected exceptional conditions.
Easy
Choose an option to check your answer.
A.
To load the pandas module and give it the alias `pd`
B.
To install Python on the computer
C.
To rename the current script as pandas
D.
To convert every variable into a DataFrame
Show Answer
Correct Answer: A. To load the pandas module and give it the alias `pd`
Explanation:
`import` makes a module’s functionality available to the program. The alias `pd` provides a shorter conventional name for referencing pandas.