First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.
Continue in the practice tool above to load more questions, 50 at a time.
Question 1Data acquisition and integration (databases, APIs, web content)
In Python's sqlite3 module, what does a Connection object represent in a typical data acquisition script?
- A cached result set returned by the last query
- A schema definition used to build tables
- A single SQL statement waiting to be executed
- The open link to a database file on which cursors operate Correct answer.
Explanation
A Connection represents an open session with a database file (or in-memory database). You create cursors from the connection and commit or roll back transactions through it. Result sets are produced by cursors, not by the connection itself.
Question 2Data acquisition and integration (databases, APIs, web content)
A developer calls cursor.execute() with a SELECT statement, then immediately calls cursor.fetchone() twice on a query that matched exactly one row. What does the second fetchone() return?
- The same row again
- A sqlite3.ProgrammingError
- An empty tuple
- None Correct answer.
Explanation
fetchone() advances the cursor; after the single matching row has been consumed, the next call returns None. It does not rewind or raise an error for exhausted results. This behavior matters when looping over results programmatically.
Question 3Data acquisition and integration (databases, APIs, web content)
Why should parameter values be passed as the second argument to cursor.execute() instead of being interpolated into the SQL string with Python formatting?
- Parameter binding is faster because it skips SQL parsing
- Parameter binding automatically commits the transaction
- Parameter binding prevents SQL injection by keeping data separate from code Correct answer.
- Parameter binding allows multiple statements to run in one call
Explanation
The database driver sends the SQL text and the parameter values separately, so user-supplied data cannot alter statement structure. This is the standard defense against SQL injection. It is not primarily a performance or transaction-control mechanism.
Question 4Data acquisition and integration (databases, APIs, web content)
What does the HTTP status code 404 indicate when a script requests a web resource for scraping?
- The server accepted the request but returned no body
- The requested resource does not exist at that URL Correct answer.
- The server is temporarily overloaded
- The client must authenticate before retrying
Explanation
404 means the server could not find a resource matching the request URI. A scraper should treat it as a missing page rather than a transient failure to retry. Authentication failures return 401 and overloaded servers typically return 503.
Question 5Data acquisition and integration (databases, APIs, web content)
Which Python standard-library module is designed to parse HTML by invoking callbacks for tags and text?
- csv
- urllib.request
- html.parser Correct answer.
- json
Explanation
html.parser provides the HTMLParser class, which processes HTML by calling methods for start tags, end tags, and text. Subclasses override these callbacks to collect data or implement other behavior. The module does not itself provide a traversable or searchable HTML tree.
Question 6Data acquisition and integration (databases, APIs, web content)
A CSV file uses semicolons as field separators. Which csv.reader call correctly handles it?
- csv.reader(file, quotechar=';')
- csv.reader(file, lineterminator=';')
- csv.reader(file, escapechar=';')
- csv.reader(file, delimiter=';') Correct answer.
Explanation
The delimiter argument tells the reader which character separates fields. quotechar and escapechar control quoting and escaping, while lineterminator affects writing. Setting delimiter to a semicolon is the correct fix.
Question 7Data acquisition and integration (databases, APIs, web content)
In a relational database, which key uniquely identifies each row of a table and cannot contain NULL values?
- Foreign key
- Candidate index
- Composite view
- Primary key Correct answer.
Explanation
A primary key enforces uniqueness and non-nullness on the chosen column or columns. Foreign keys reference other tables and may allow NULLs. Indexes and views do not define row identity.
Question 8Data acquisition and integration (databases, APIs, web content)
A script fetches JSON from an API and calls json.loads() on the response text. What Python object does a JSON object literal become?
- A set
- A tuple
- A list
- A dict Correct answer.
Explanation
JSON objects map to Python dictionaries, JSON arrays map to lists, and JSON strings, numbers, booleans, and null map to their Python equivalents. Tuples and sets have no direct JSON representation.
Question 9Data acquisition and integration (databases, APIs, web content)
What is the purpose of the requests library's timeout parameter in a data acquisition script?
- To limit the size of the response body
- To abort the request if the server does not respond within a set period Correct answer.
- To retry the request a fixed number of times
- To cache the response for later requests
Explanation
timeout sets a limit on how long the client waits for the server to send data, preventing a script from hanging indefinitely. It does not cap body size, retry, or cache. Retries require separate logic or an adapter.
Question 10Data acquisition and integration (databases, APIs, web content)
A scraper must extract all href attribute values from anchor tags in a page. Which approach directly targets that data?
- Calling response.text.split() and counting tokens
- Calling response.json() and indexing the result
- Reading response.status_code for each link
- Iterating over parsed anchor elements and reading their href attributes Correct answer.
Explanation
Parsing the document into elements and reading each anchor's href attribute retrieves the link targets reliably. String splitting is fragile and status_code describes one response, not link targets. The page is HTML, so response.json() does not apply.
Question 11Data acquisition and integration (databases, APIs, web content)
A developer wants to insert many rows into SQLite efficiently. Which practice gives the best throughput?
- Calling fetchall() after each insert
- Opening a new connection for each row
- Wrapping many inserts in one transaction and committing once Correct answer.
- Committing after every single insert
Explanation
Each commit forces the database to flush to disk, so batching many inserts in one transaction greatly reduces overhead. Reusing one connection also avoids setup cost. Fetching results after inserts is irrelevant to write speed.
Question 12Data acquisition and integration (databases, APIs, web content)
When joining two tables, what does an INNER JOIN return?
- Only rows where the join condition matches in both tables Correct answer.
- Only rows present in the right table
- All rows from both tables regardless of matches
- All rows from the left table with NULLs where the right has no match
Explanation
INNER JOIN keeps only combinations where the join predicate is satisfied in both tables. Left and right outer joins preserve unmatched rows with NULLs. A cross join produces all combinations without a predicate.
Question 13Data acquisition and integration (databases, APIs, web content)
An API returns paginated results with a 'next' cursor field. What is the correct strategy to collect all records?
- Ignore pagination and parse only the first page
- Request the first page repeatedly until the response is empty
- Follow the 'next' cursor until it is absent or null Correct answer.
- Increase the page size until one page holds everything
Explanation
Cursor-based pagination requires requesting successive pages using the provided cursor until the API signals there are no more pages. Re-requesting the first page loops forever, and ignoring pagination loses data. Some APIs cap page size, so enlarging it is not a general solution.
Question 14Data acquisition and integration (databases, APIs, web content)
Which HTTP method is conventionally used to retrieve data from a REST API without modifying server state?
- PUT
- POST
- DELETE
- GET Correct answer.
Explanation
GET requests are defined as safe and idempotent reads that should not change server state. POST typically creates resources, PUT replaces them, and DELETE removes them. Using GET for reads is standard REST practice.
Question 15Data acquisition and integration (databases, APIs, web content)
A response from an API has Content-Type application/json. Which parsing step is appropriate?
- Decode the body with json.loads() or response.json() Correct answer.
- Read the body with csv.DictReader
- Parse the body with an HTML parser
- Split the body on commas into fields
Explanation
A JSON content type means the body is JSON text, which should be decoded with a JSON parser such as json.loads() or the library's helper. HTML, CSV, and naive splitting assume different formats and would fail or produce wrong results.
Question 16Data acquisition and integration (databases, APIs, web content)
A web page renders its data with client-side JavaScript after load. Why might a simple HTTP GET plus HTML parser return no data rows?
- The rows are inserted into the DOM by JavaScript the parser never executes Correct answer.
- HTML parsers cannot read table elements
- The server blocks all HTTP clients by default
- The response status is always 204
Explanation
A plain GET retrieves the initial HTML but does not run JavaScript, so content injected later is absent from the parsed document. A headless browser or an underlying API call is needed. Tables are perfectly parseable when present in the HTML.
Question 17Data acquisition and integration (databases, APIs, web content)
When scraping a site, why is it important to respect the robots.txt file and site terms?
- It encrypts the response automatically
- It defines permitted crawling behavior and legal/ethical boundaries Correct answer.
- It guarantees the site returns JSON
- It improves the parser's accuracy
Explanation
robots.txt communicates which paths crawlers may access, and site terms define acceptable use. Respecting them avoids legal and ethical problems and reduces server load. It does not affect parsing accuracy, encryption, or response format.
Question 18Data acquisition and integration (databases, APIs, web content)
A developer connects to a database and runs several INSERT statements, then the script crashes before commit. What is the state of those inserts after reconnecting?
- They are saved but marked invalid
- They are rolled back and absent Correct answer.
- They are queued for the next commit
- They are permanently saved
Explanation
Uncommitted changes belong to an open transaction that is discarded when the connection ends without commit. The database returns to its last committed state. There is no automatic later commit of orphaned changes.
Question 19Data acquisition and integration (databases, APIs, web content)
Which SQL clause is used to filter groups produced by GROUP BY based on an aggregate condition?
- WHERE
- ORDER BY
- LIMIT
- HAVING Correct answer.
Explanation
HAVING filters after grouping and may reference aggregates such as COUNT or SUM. WHERE filters individual rows before grouping. ORDER BY sorts and LIMIT restricts row count.
Question 20Data acquisition and integration (databases, APIs, web content)
A CSV file has a header row and the code uses csv.DictReader(f). What does each iteration yield?
- A string of the raw line
- A dict mapping header names to row values Correct answer.
- A tuple of column indexes
- A list of all field values
Explanation
DictReader uses the first row as keys and returns one dictionary per subsequent row, mapping each header to its value. Plain csv.reader returns lists, and neither returns raw strings or index tuples.
Question 21Data acquisition and integration (databases, APIs, web content)
An API enforces rate limits and returns 429 with a Retry-After header. What is the most correct client behavior?
- Switch to POST to bypass the limit
- Delete the Retry-After header and retry
- Wait for the indicated period before retrying, with backoff Correct answer.
- Immediately resend the request in a tight loop
Explanation
A 429 response means the client exceeded its allowance, and Retry-After indicates how long to wait. Honoring it, ideally with exponential backoff, avoids further throttling. Tight loops worsen the problem, and changing methods does not bypass quotas.
Question 22Data acquisition and integration (databases, APIs, web content)
A query joins a large table to a small table on an indexed column but runs slowly. Which change is most likely to help?
- Removing the index on the join column
- Adding ORDER BY on an unindexed column
- Ensuring statistics are current and the join uses the index Correct answer.
- Selecting all columns with SELECT *
Explanation
The query planner relies on statistics to choose an index-based join; stale statistics can cause a poor plan. Removing the index or adding sorting on an unindexed column usually hurts. SELECT * increases I/O and memory use.
Question 23Data acquisition and integration (databases, APIs, web content)
A scraper must combine data from two sources: a database table of product IDs and a JSON API returning details per ID. Which design avoids excessive API calls while keeping data consistent?
- Call the API once per row inside a loop with no batching
- Store API responses without any key and match by position
- Discard IDs that return errors and continue silently
- Fetch IDs, batch API requests where supported, and reconcile results by ID Correct answer.
Explanation
Fetching IDs first and batching requests reduces call volume and respects limits, while reconciling by ID preserves correctness. Per-row calls scale poorly, positional matching is fragile, and silently dropping failures hides data gaps.
Question 24Data acquisition and integration (databases, APIs, web content)
Two tables store the same customer with slightly different names, and a join on the name column returns no matches. Which approach best addresses this integration problem?
- Remove the name column from both tables
- Lowercase both names and assume they then match exactly
- Increase the join to a CROSS JOIN to force matches
- Join on a stable surrogate or natural identifier instead of the free-text name Correct answer.
Explanation
Free-text names vary in spelling, spacing, and case, so joining on a stable key such as a customer ID is reliable. Casing alone rarely resolves real variation, and a cross join produces meaningless combinations. Dropping data does not solve matching.
Question 25Data acquisition and integration (databases, APIs, web content)
A pipeline fetches JSON, transforms it, and loads it into a database. A run fails midway after some rows are inserted. Which property ensures the load is all-or-nothing?
- Atomicity Correct answer.
- Latency
- Idempotency
- Cardinality
Explanation
Atomicity guarantees a transaction applies completely or not at all, so a mid-run failure leaves no partial load. Idempotency means rerunning produces the same result but does not itself prevent partial writes. Latency and cardinality are unrelated concepts.
Question 26Data cleaning and validation
In a PCAD-style pipeline, which activity belongs to the data validation stage rather than to data cleaning?
- Replacing missing postal codes with a default value
- Standardizing country names to a single casing convention
- Removing duplicate customer rows detected by a composite key
- Verifying that each record's age field falls within the permitted 0–120 range Correct answer.
Explanation
Validation checks whether data conforms to declared rules, ranges, formats, or constraints, so a range check on an age field is a validation activity. Cleaning changes the data itself, such as imputing, standardizing, or deduplicating records.
Question 27Data cleaning and validation
A dataset stores a numeric measurement as text values such as "12,5" and "1.234,56". Which cleaning step most directly addresses this issue before numeric analysis?
- Drop every row containing a comma
- Replace all commas with semicolons
- Convert the column to a consistent decimal separator and numeric type Correct answer.
- Sort the column alphabetically to spot anomalies
Explanation
Mixed locale formatting must be normalized to one decimal separator and then cast to a numeric type so arithmetic works correctly. Dropping rows or sorting does not fix the underlying type and format inconsistency.
Question 28Data cleaning and validation
Which technique best detects outliers in a numeric column without assuming a normal distribution?
- Chi-square test of independence
- Pearson correlation with a second column
- Simple random sampling of ten rows
- The interquartile range rule using the 1.5×IQR fences Correct answer.
Explanation
The IQR rule flags values beyond Q1 − 1.5×IQR or Q3 + 1.5×IQR and makes no normality assumption. Correlation, chi-square, and sampling do not provide distribution-free outlier fences.
Question 29Data cleaning and validation
A table has a column of email addresses. Which validation rule type is most appropriate to confirm that each value has the expected structure?
- A uniqueness constraint on the primary key
- Referential integrity against a lookup table
- A format or pattern check using a regular expression Correct answer.
- A foreign key constraint to the customer table
Explanation
A pattern check verifies that a value matches an expected structure such as an email format. Referential and key constraints enforce relationships and uniqueness, not value structure.
Question 30Data cleaning and validation
Which statement describes the purpose of a data profiling step at the start of a cleaning project?
- It permanently deletes suspicious records
- It trains the final predictive model
- It encrypts sensitive fields for storage
- It summarizes column statistics, types, and patterns to reveal quality issues Correct answer.
Explanation
Profiling produces statistics such as null counts, distinct counts, min/max, and pattern frequencies that expose quality problems before cleaning decisions are made. It is diagnostic and does not itself delete, model, or encrypt data.
Question 31Data cleaning and validation
A customer table stores the same person twice with slightly different names, e.g., "Jon Smith" and "John Smith". Which cleaning task addresses this?
- One-hot encoding of the name column
- Outlier capping with winsorization
- Record linkage or fuzzy matching to identify probable duplicates Correct answer.
- Column type casting to integer
Explanation
When duplicates differ by small spelling variations, exact matching fails, so fuzzy matching or record linkage compares similarity to flag probable duplicates. Type casting, outlier capping, and encoding do not resolve near-duplicate identity.
Question 32Data cleaning and validation
Which action is an example of data normalization rather than data standardization?
- Mapping "USA", "U.S.", and "United States" to one canonical label
- Scaling a numeric column to the range 0–1 using min-max scaling Correct answer.
- Converting all phone numbers to the E.164 format
- Trimming leading and trailing whitespace from text fields
Explanation
In data preparation, normalization often refers to rescaling numeric values into a common range such as 0–1. Canonical label mapping, format conversion, and whitespace trimming are standardization or cleansing operations.
Question 33Data cleaning and validation
A validation report shows that 40% of rows have a missing value in the "region" column. Which first step is most appropriate before choosing an imputation strategy?
- Replace missing values with the most frequent region and stop
- Investigate whether missingness is random or related to other variables Correct answer.
- Impute all missing regions with the string "UNKNOWN" immediately
- Delete the region column without further inspection
Explanation
Understanding the missingness mechanism determines whether imputation, deletion, or model-based handling is appropriate. Acting before diagnosis risks bias or unnecessary data loss.
Question 34Data cleaning and validation
Which SQL construct most directly enforces that a column cannot contain NULL values?
- A CHECK constraint allowing any value
- A NOT NULL constraint on the column Correct answer.
- An index on the column
- A DEFAULT clause on the column
Explanation
A NOT NULL constraint rejects rows where the column is null, enforcing completeness at the schema level. CHECK, DEFAULT, and indexes do not by themselves prohibit nulls.
Question 35Data cleaning and validation
A dataset of order totals contains a single value of 9,999,999 while all other values are below 500. What is the most defensible first action?
- Flag the value and investigate whether it is a legitimate large order or a data entry error Correct answer.
- Cap the value at 500 without investigation
- Replace the value with the column mean
- Delete the row immediately as an error
Explanation
Extreme values may be genuine business events or errors, so they should be flagged and investigated before any treatment. Deleting, capping, or imputing without investigation can destroy valid information.
Question 36Data cleaning and validation
Which validation approach best confirms that every value in an orders table's customer_id column exists in the customers table?
- A uniqueness check on customer_id
- A range check on customer_id
- A referential integrity check against the customers table Correct answer.
- A pattern check on customer_id
Explanation
Referential integrity verifies that foreign key values match existing primary keys in the referenced table. Range, uniqueness, and pattern checks test other properties and would not detect orphaned references.
Question 37Data cleaning and validation
A column storing dates contains values in both "YYYY-MM-DD" and "DD/MM/YYYY" formats, and some values such as "03/04/2024" are ambiguous. Which approach is most robust?
- Apply one parser to all values and accept the default interpretation
- Parse per source or locale where available, and flag ambiguous values for review Correct answer.
- Convert every date to a string and compare lexicographically
- Discard all ambiguous dates
Explanation
Ambiguous dates must be resolved with source or locale context, and unresolved cases should be flagged rather than guessed. A single default parser or lexicographic comparison would silently produce wrong dates.
Question 38Data cleaning and validation
Which pair of metrics most directly quantifies duplicate records in a dataset?
- Mean and standard deviation of a numeric column
- Cardinality and null count of a text column
- Precision and recall of a duplicate-detection rule Correct answer.
- Skewness and kurtosis
Explanation
Duplicate detection is a classification problem, so precision and recall measure how many flagged pairs are true duplicates and how many true duplicates were found. The other statistics describe distributions or column properties.
Question 39Data cleaning and validation
What does a consistency check verify in a relational dataset?
- That all text is lowercase
- That every column uses the same data type
- That values across related fields or tables agree with each other Correct answer.
- That the dataset fits in memory
Explanation
Consistency checks confirm that related values do not contradict each other, for example an order ship date that is not earlier than its order date or totals that match line items. Type uniformity, memory fit, and casing are unrelated concerns.
Question 40Data cleaning and validation
A cleaning script replaces missing numeric values with the column mean. Under which condition is this imputation most likely to bias downstream analysis?
- When missingness is completely at random and the fraction missing is very small
- When the column is a unique identifier
- When the column has a symmetric distribution and no missing values
- When missingness is systematically related to the value itself, such as high earners declining to report income Correct answer.
Explanation
Mean imputation assumes missingness is unrelated to the value; when high values are preferentially missing, the mean is pulled down and imputed values understate the true level. Random, small-fraction missingness is far less problematic.
Question 41Data cleaning and validation
Which transformation is appropriate for a numeric feature with a heavily right-skewed distribution before applying distance-based algorithms?
- One-hot encoding of the feature
- Converting the feature to a categorical label
- Removing the feature entirely
- A log or Box-Cox transformation to reduce skew Correct answer.
Explanation
Log or Box-Cox transformations compress large values and reduce skew, making distance-based methods less dominated by extreme values. Encoding, removal, or categorization either discards information or does not address skew.
Question 42Data cleaning and validation
Which statement best describes the role of a validation rule set in an automated data pipeline?
- It replaces the need for any data profiling
- It documents past cleaning decisions for auditors only
- It guarantees that all records are accurate
- It programmatically rejects, quarantines, or flags records that violate declared constraints Correct answer.
Explanation
A validation rule set encodes constraints so the pipeline can automatically route nonconforming records to rejection, quarantine, or flagging. It does not by itself guarantee accuracy and does not replace profiling.
Question 43Data cleaning and validation
A text column contains values with inconsistent casing and stray spaces, e.g., " New York", "new york ", and "NEW YORK". Which sequence most reliably produces a single canonical category?
- Sort the column and keep the first value seen
- Trim whitespace, apply consistent casing, then map to a canonical label Correct answer.
- Remove all rows that differ from the most common value
- Hash each value and group by hash
Explanation
Trimming removes stray whitespace, consistent casing removes case differences, and canonical mapping resolves remaining variants. Sorting, hashing, or deleting variant rows does not unify the categories correctly.
Question 44Data cleaning and validation
Which scenario most clearly indicates a violation of a uniqueness constraint in a customer dataset?
- Two records have the identical customer_id value Correct answer.
- A customer has a null middle name
- Two customers share the same city
- A customer's phone number uses a different format
Explanation
A uniqueness constraint requires each key value to appear at most once, so two records with the same customer_id violate it. Shared cities, null middle names, and format differences do not breach key uniqueness.
Question 45Data cleaning and validation
An analyst wants to detect whether a categorical column contains values outside an approved code list. Which validation technique applies?
- A date format check
- A referential integrity check on a foreign key
- A range check on numeric bounds
- A domain or allowed-value check Correct answer.
Explanation
A domain check confirms that each value belongs to a defined set of permitted codes. Range checks apply to ordered numerics, referential checks to relationships, and date checks to temporal formats.
Question 46Data cleaning and validation
A pipeline uses fuzzy matching to merge customer records. Raising the similarity threshold from 0.80 to 0.95 will most likely have which effect?
- More false positives and fewer false negatives
- More true positives and fewer false negatives
- No change in either error type
- Fewer false positives and more false negatives Correct answer.
Explanation
A stricter threshold requires greater similarity before two records are merged, so borderline pairs are no longer matched. This reduces incorrect merges (false positives) but increases missed true duplicates (false negatives).
Question 47Data cleaning and validation
A dataset has missing values in a column that are not missing at random and are strongly predicted by other observed columns. Which imputation approach is most principled?
- Multiple imputation or model-based imputation using the predictive columns Correct answer.
- Filling with a fixed sentinel value such as -999
- Listwise deletion of all rows with any missing value
- Mean imputation using the overall column mean
Explanation
When missingness depends on observed variables, model-based or multiple imputation can leverage those predictors and propagate uncertainty appropriately. Overall mean imputation ignores the predictors, and sentinel values can distort analysis.
Question 48Data cleaning and validation
Two validation rules are applied to a numeric field: value ≥ 0 and value ≤ 100. A record contains 150. Which classification is correct?
- It cannot be evaluated without profiling
- It passes both rules because it is a number
- It violates the upper-bound rule only Correct answer.
- It violates both the lower-bound and upper-bound rules
Explanation
The value 150 satisfies the nonnegative condition but exceeds the maximum of 100, so only the upper-bound rule is violated. The lower-bound rule is satisfied because 150 is greater than or equal to zero.
Question 49Data cleaning and validation
A cleaning process applies a global z-score filter that removes values with |z| > 3 to a column containing a legitimate cluster of high-value enterprise transactions. What is the main risk?
- It may systematically remove valid minority-group records, introducing selection bias Correct answer.
- It will guarantee the column is normally distributed
- It will retain all legitimate transactions and remove only errors
- It will convert the column to a categorical type
Explanation
Global statistical filters assume a single distribution and can delete genuine subpopulation values, here the enterprise transactions, biasing the remaining sample. Outlier rules should be applied with business context or within relevant segments.
Question 50Data cleaning and validation
A validation report shows 98% of records pass all rules, but the 2% failures are concentrated entirely in one source system. What is the most useful interpretation?
- The failing records should be deleted to raise the pass rate
- The failure pattern suggests a source-specific defect that should be investigated at ingestion Correct answer.
- The overall pass rate proves the data is clean
- The rules are too strict and should be removed
Explanation
Concentration of failures in one source points to a systematic cause such as a schema mismatch or encoding issue in that feed, which should be fixed at ingestion. The aggregate pass rate hides this pattern, and deleting records or rules hides the defect.