1. Home
  2. MCQs by exam
  3. PPSC IT
  4. Data Science

PPSC IT MCQs – Data Science · Page 3

231 multiple choice questions typical of the PPSC IT exam, with answers and explanations. Switch on practice mode to test yourself first.

Showing 51–75 of 231

SELECT * FROM events LIMIT 10; is run repeatedly on a large table. Why can the returned rows differ between executions?

  1. LIMIT samples rows randomly unless a repeatable seed is supplied with the statement
  2. Without ORDER BY no row order is guaranteed, so the plan may return any ten rows Correct answer
  3. LIMIT is applied before the WHERE clause, so different rows qualify on each run
  4. The table's primary key is used implicitly, and keys are regenerated on each read
MCQSEXAM Read explanation

SELECT DISTINCT city, country FROM customers; is executed. What exactly is deduplicated?

  1. Only the city column, because DISTINCT applies to the first selected expression only
  2. Only the country column, since the last expression in the list takes precedence
  3. Both columns independently, producing the cross product of unique values
  4. Whole (city, country) pairs, so a city may still appear once per distinct country Correct answer
MCQSEXAM Read explanation

SELECT COUNT(*) FROM orders HAVING COUNT(*) > 100; is valid in PostgreSQL. What does HAVING do when no GROUP BY is written?

  1. It forms implicit groups from every selected column of the query output
  2. It filters the single implicit group, returning either one row or no rows at all Correct answer
  3. It is a syntax error, because HAVING always requires an explicit GROUP BY clause
  4. It filters individual rows before aggregation, exactly as a WHERE clause would
MCQSEXAM Read explanation

LogisticRegression(class_weight='balanced') is fitted on 1000 rows with 100 positives. What weight does the positive class receive?

  1. 1.0, because balanced weighting only rescales the intercept term of the model
  2. 0.1, because the minority class is down-weighted to match the majority count
  3. 5.0, computed as n_samples divided by the product of classes and positives Correct answer
  4. 10.0, computed as the ratio of negatives to positives in the training data
MCQSEXAM Read explanation

A ColumnTransformer applies OneHotEncoder to two columns with remainder='passthrough'. What does the fitted output contain?

  1. Only numeric columns, since passthrough drops anything it cannot encode
  2. Encoded columns followed by every unlisted column appended unchanged in order Correct answer
  3. Only the encoded columns, because remainder='passthrough' keeps no other column at all
  4. The encoded columns plus a copy of the input frame, so all columns appear twice
MCQSEXAM Read explanation

A Pipeline is built as Pipeline([('scale', StandardScaler()), ('model', LogisticRegression())]). How is C changed through set_params?

  1. pipeline.set_params(model.C=0.1), using dotted attribute notation for the step
  2. pipeline.set_params('model__C'=0.1), passing the parameter name as a quoted string
  3. pipeline.set_params(model__C=0.1), using the step name and a double underscore Correct answer
  4. pipeline.set_params(C=0.1), because parameters are flattened onto the pipeline itself
MCQSEXAM Read explanation

GridSearchCV(scoring='f1') is used with a classifier and cv left at its default. Which splitter is applied?

  1. StratifiedKFold with 5 splits, which preserves each class ratio inside every fold Correct answer
  2. KFold with 5 splits and no shuffling, which keeps the original row ordering fully intact
  3. LeaveOneOut, because grid search always maximises the number of fitted models
  4. TimeSeriesSplit, because f1 scoring requires chronologically ordered folds here
MCQSEXAM Read explanation

For a binary SVC, predict uses decision_function internally. What decision rule is applied by default?

  1. The score is compared with the training mean, which recentres the decision boundary
  2. The sign of the score decides the class, with positive scores mapped to classes_[1] here Correct answer
  3. The score is thresholded at 0.5, exactly mirroring a probability cut-off on a calibrated model
  4. The class with the larger absolute score wins, regardless of the score's overall sign
MCQSEXAM Read explanation

A column in the training data is entirely NaN. What does SimpleImputer(strategy='mean') do with it by default?

  1. It fills the column with zeros, because an undefined mean is replaced by zero
  2. It raises a ValueError, since no statistic at all can be computed from an empty column
  3. It keeps the column and fills it with NaN, preserving the missing-value marker
  4. It drops the column from the transformed output and ignores it during transform Correct answer
MCQSEXAM Read explanation

KMeans is run with n_init=10. What does that parameter control, and why does the default matter?

  1. The number of clusters tested, since n_init is simply an alias for n_clusters in the API
  2. The number of bootstrap samples used to estimate cluster stability scores
  3. The number of independent initialisations, with the lowest-inertia run being kept Correct answer
  4. The number of iterations allowed inside a single Lloyd run before it stops
MCQSEXAM Read explanation

Why is LabelEncoder unsuitable for encoding a categorical feature column before fitting a linear model?

  1. It imposes an arbitrary ordinal order, which the model then treats as numeric distance Correct answer
  2. It fails on columns that contain more than two distinct categories at once
  3. It returns one-hot columns, which cause perfect multicollinearity in the design matrix
  4. It only works on the target vector, so calling it on a feature column raises an error
MCQSEXAM Read explanation

What does n_jobs=-1 change about a scikit-learn estimator such as RandomForestClassifier?

  1. It sets the number of trees to the core count, overriding n_estimators entirely
  2. It spreads independent fits over all available cores, without changing the results Correct answer
  3. It repeats the fit once per available core and averages the resulting forests together
  4. It disables parallel execution, because -1 means a single worker thread here
MCQSEXAM Read explanation

Why is scaler.fit_transform(X_train) followed by scaler.transform(X_test) correct, while scaler.fit_transform(X_test) is not?

  1. The scaler requires the test set to be a subset of the training rows it was fitted on
  2. Fitting on the test set leaks its statistics into preprocessing and inflates scores Correct answer
  3. transform must be called before fit on the training set to establish the column order
  4. fit_transform on the test set is slower, yet returns an identical result
MCQSEXAM Read explanation

A fraud classifier labels 99 of 100 test transactions as legitimate and reports accuracy 0.99. Which metric exposes the problem fastest?

  1. The confusion matrix sum, which grows whenever accuracy is artificially high
  2. R-squared, which measures how much variance the fraud labels explain overall
  3. Balanced accuracy, which averages recall across both classes and lands near 0.50 Correct answer
  4. Precision, which stays high because most of the predicted negatives are truly negative
MCQSEXAM Read explanation

df.query('price > @limit') is evaluated inside a function that holds limit as a local variable. Why does this work?

  1. The @ prefix escapes the name, allowing identifiers that are not valid Python
  2. The @ prefix resolves the name in the caller's scope instead of as a column label Correct answer
  3. The @ prefix marks the referenced name as a pandas Series, so query can broadcast it
  4. The @ prefix disables parsing of the expression, passing it to Python's eval directly
MCQSEXAM Read explanation

What does groupby(...).apply(f) do with the grouping columns when f returns a DataFrame in pandas 2.x?

  1. It drops the grouping columns entirely, since apply only ever sees the remaining value columns
  2. It raises an error, because apply callbacks returning DataFrames are no longer supported
  3. It duplicates the keys as columns and as index levels, producing redundant result fields
  4. It prepends the group keys to the result index, so include_groups=False changes the output Correct answer
MCQSEXAM Read explanation

Under the copy-on-write semantics of pandas 2.x, df[df.a > 0]['b'] = 1 is executed. What is the effect?

  1. The whole column b is set to 1 for every row, since the mask is ignored here
  2. Nothing changes in df, because the chained assignment writes to a temporary copy Correct answer
  3. Column b is updated for the matching rows, exactly as an equivalent .loc assignment would
  4. A SettingWithCopyWarning is raised and the assignment is then silently applied
MCQSEXAM Read explanation

df.drop_duplicates(subset=['email'], keep='last') is applied to a frame with repeated emails. What is retained?

  1. The last row of the frame only, because keep applies to the whole frame rather than rows
  2. Both the first and last occurrences, since keep='last' keeps the boundary rows intact
  3. The last occurrence of each email in the current row order, dropping the earlier ones Correct answer
  4. The first occurrence of each email address, because keep names the copy inspected
MCQSEXAM Read explanation

A column holds integers and NaN. Why does astype('int64') fail, and what is the usual fix?

  1. The cast truncates NaN to zero, raising a warning rather than an error
  2. The fix is to cast to float16 first, because float16 supports missing values natively
  3. int64 has no NaN representation, so the nullable Int64 dtype must be used instead Correct answer
  4. int64 holds NaN perfectly well, but the cast is refused because of an unrelated mismatch
MCQSEXAM Read explanation

df.resample('M').sum() is called on a DataFrame whose date lives in an ordinary string column rather than the index. What happens?

  1. The call groups by calendar month names, treating the strings as categorical data
  2. An empty frame is returned, because no rows fall on the month-end timestamps
  3. A TypeError about the index, because resample needs a DatetimeIndex on the axis Correct answer
  4. The string column is parsed automatically and the monthly totals are returned
MCQSEXAM Read explanation

A categorical column with 20 categories is grouped, but only 3 categories occur in the data. Why does observed=True shrink the result?

  1. Because observed=True drops rows whose category does not appear among the group keys chosen
  2. Because grouping a categorical converts it to an object column, losing category metadata
  3. Because observed=True sorts the categories and then truncates the output index
  4. Because the default expands every category combination, producing empty groups too Correct answer
MCQSEXAM Read explanation