1. Home
  2. MCQs by exam
  3. NTS
  4. Data Science

NTS MCQs – Data Science · Page 2

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

Showing 26–50 of 266

In scikit-learn's LogisticRegression, what does a very small value of C do to the fitted model?

  1. It applies weak regularisation, allowing the coefficients to grow freely
  2. It disables regularisation entirely, matching unpenalised maximum likelihood
  3. It caps the number of solver iterations, so the fit stops early in training
  4. It applies strong regularisation, shrinking the coefficients toward zero Correct answer
MCQSEXAM Read explanation

A pattern capturing one or more digits is applied with Series.str.extract to a column where some values do not match. What appears in those rows?

  1. NaN in the extracted column, because a non-match yields a missing value Correct answer
  2. An empty string, because extract returns the unmatched part of the input
  3. The original value unchanged, since extract only rewrites matching rows
  4. An error, because extract requires every value to match the pattern
MCQSEXAM Read explanation

SELECT city FROM a EXCEPT SELECT city FROM b; is run where both sides contain a NULL city. How are those NULLs treated?

  1. They are treated as unknown, so every NULL row survives in the resulting output
  2. They abort the query, because set operators reject NULL values in any column
  3. They are duplicated, since set operators never collapse duplicate NULLs
  4. They are treated as equal, so the NULL row is removed from the difference Correct answer
MCQSEXAM Read explanation

SUM(amount) OVER (PARTITION BY account ORDER BY day) is used as a running total. Which frame does the default produce?

  1. RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, which also includes rows tied on day Correct answer
  2. ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, counting only physical rows read
  3. RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, which totals the whole partition
  4. ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING, a reverse running total by default
MCQSEXAM Read explanation

A query divides two integer columns as 7 / 2. What is returned, and how is a decimal result obtained?

  1. An error, because dividing two integers requires an explicit CAST in standard SQL
  2. 3, because integer division truncates; cast one operand to numeric to get 3.5 Correct answer
  3. 3.5, because SQL always performs division in floating point internally
  4. 4, because SQL rounds the exact quotient half up when both operands are ints
MCQSEXAM Read explanation

SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1; is run. What does it return?

  1. Every row whose email appears more than once in the table, one row per duplicate
  2. One row per distinct email, including those that appear exactly once in users
  3. One row per email, with the count replaced by the number of distinct duplicates
  4. One row per duplicated email, with the number of occurrences in the count column Correct answer
MCQSEXAM Read explanation

SELECT dept, AVG(salary) FROM staff WHERE AVG(salary) > 50000 GROUP BY dept; fails. Why?

  1. AVG cannot appear in both the select list and the filter of the same query
  2. The GROUP BY clause must also list AVG(salary) explicitly so the aggregate has a name
  3. Aggregates are only permitted in the select list and in the ORDER BY clause
  4. WHERE runs before grouping, so no aggregate exists yet; HAVING must filter instead Correct answer
MCQSEXAM Read explanation

SELECT COUNT(CASE WHEN status = 'late' THEN 1 END) AS late FROM loans; is executed. How does the result differ from COUNT(*)?

  1. It counts every row, because COUNT ignores the NULL result of the CASE expression
  2. It counts late rows twice, since the CASE duplicates every row that matches
  3. It fails, because COUNT cannot accept a CASE expression as its only argument
  4. It counts only late rows, because the CASE yields NULL for all other statuses Correct answer
MCQSEXAM Read explanation

An expression computes revenue / items and items may be zero. Which construct prevents a division-by-zero error, and how?

  1. NULLIF(items, 0), which returns NULL for a zero divisor so the result becomes NULL Correct answer
  2. COALESCE(items, 0), which substitutes a zero divisor so that the division stays exact
  3. NULLIF(items, 0), which replaces NULL divisors with zero and skips those rows
  4. COALESCE(items, 0), which converts a zero divisor into a NULL before dividing
MCQSEXAM Read explanation

A subquery used with NOT IN returns a NULL among its values. What happens to the outer query's result?

  1. It returns the same rows as NOT EXISTS would, since NULLs are ignored by NOT IN
  2. It raises an error, because NOT IN refuses subqueries that can produce NULL
  3. It returns only the rows whose key is itself NULL, treating NULL as a match
  4. It returns no rows at all, because every comparison with NULL yields unknown Correct answer
MCQSEXAM Read explanation

SELECT price * qty AS total FROM items ORDER BY total DESC; works in PostgreSQL. What is total referring to?

  1. The original column named total, since aliases are never visible to ORDER BY
  2. A positional reference, because total is parsed as the second select expression
  3. A re-evaluated expression, since ORDER BY recomputes price times qty again
  4. The output column alias, which ORDER BY accepts even though WHERE does not Correct answer
MCQSEXAM Read explanation