1. Home
  2. MCQs by exam
  3. PPSC IT

PPSC IT MCQs · Page 6

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

Showing 126–150 of 577

What does setting random_state in train_test_split guarantee?

  1. The rows are shuffled in place, so the original DataFrame's order is permanently changed
  2. The same split is produced on repeated runs with the same inputs and library version Correct answer
  3. Every run is statistically independent, so no split pattern can ever repeat itself
  4. The split is stratified automatically, keeping class proportions in both partitions
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

A skewed income column must be split into four groups of equal count. Which function does that, and what does the other do instead?

  1. qcut, which uses sample quantiles, whereas cut splits on equal-width value ranges Correct answer
  2. cut, which uses sample quantiles, whereas qcut splits on equal-width value ranges
  3. cut, because both functions are identical except for the naming of their labels
  4. qcut, because it always produces equal-width bins regardless of the data distribution
MCQSEXAM Read explanation

df['city'].isin(['Lahore', 'Karachi']) is used as a row filter. What does it return, and how are NaN rows treated?

  1. A boolean Series aligned to the index, with NaN rows marked False unless NaN is listed Correct answer
  2. A boolean Series of identical length, with NaN rows marked True so every record is kept
  3. An integer array of row positions, because isin returns the matching row numbers
  4. A filtered DataFrame directly, since isin applies the mask as soon as it is called
MCQSEXAM Read explanation

A wide table with one column per month must become long, with month and value columns. Which call does that?

  1. df.transpose, which swaps rows and columns and therefore creates a long form table
  2. df.melt with id_vars, which turns the monthly columns into rows of key-value pairs Correct answer
  3. df.pivot with the month columns as index, which expands the columns into extra rows
  4. df.stack on axis=1, which returns a wide frame with the months kept as columns
MCQSEXAM Read explanation

df.pivot_table(index='dept', columns='month', values='sales') is called without aggfunc. What happens when several rows share a dept and month?

  1. The duplicate cells are averaged, because the default aggregation is the mean Correct answer
  2. A ValueError is raised, because duplicate entries need an explicit aggfunc
  3. The last row for each cell wins, because pivot_table keeps the final value
  4. The rows are concatenated into a list inside the cell, preserving every value
MCQSEXAM Read explanation

A workload streams 10 TB a month out to the internet while ingesting the same volume. Which cost dominates, and why?

  1. Egress dominates, because data transferred out to the internet is billed and inbound is free Correct answer
  2. Ingress dominates, because inbound data is billed per gigabyte while outbound egress is free of charge
  3. They cost the same, because both directions are billed at the identical per-gigabyte rate today
  4. Neither is billed, because traffic remains free while it stays within a single AWS region
MCQSEXAM Read explanation

A bucket replicates to another region with S3 Cross-Region Replication. What recovery point objective does the replica give?

  1. The bucket's versioning window, because the replica retains every prior object version written
  2. Near-zero but not zero, because replication is asynchronous and may lag by seconds or minutes Correct answer
  3. Exactly zero, because replication is synchronous and commits the object to both regions together
  4. Zero for new objects only, since existing objects are copied synchronously when it is enabled
MCQSEXAM Read explanation

A table is written with 10 items per second, each item 6 KB in size. How many write capacity units are needed?

  1. 10, because DynamoDB charges one write unit per item regardless of the individual item size
  2. 30, because each item rounds up to three units and the remaining size is ignored here
  3. 120, because writes are billed twice over when the table uses eventual consistency
  4. 60, because each 6 KB item consumes six write units and ten are written per second Correct answer
MCQSEXAM Read explanation

A VPC subnet is created with CIDR 10.0.4.0/24 in AWS. How many IP addresses can actually be assigned to resources?

  1. 254, because only the network and broadcast addresses are unusable inside a subnet here
  2. 250, because AWS reserves six addresses once the VPC router is also counted
  3. 251, because AWS reserves five addresses in every subnet for networking functions Correct answer
  4. 256, because a /24 mask leaves eight host bits with no addresses reserved
MCQSEXAM Read explanation

In KMS envelope encryption, what is the role of the data key?

  1. It replaces the customer master key for all requests, sharply reducing KMS API call volume
  2. It is a plaintext credential that must be rotated manually with every object written
  3. It encrypts the data locally, and is itself stored encrypted under a KMS customer key Correct answer
  4. It encrypts the customer master key, so the master key never leaves the KMS service
MCQSEXAM Read explanation

A static site on CloudFront must serve a corrected file immediately everywhere. Which approach avoids stale edge copies most reliably?

  1. Issue an invalidation for /* first, then upload the fixed file to the same key
  2. Set the origin's Cache-Control max-age to zero, which flushes all existing edge copies at once
  3. Reduce the default TTL to 60 seconds, which bounds how long an edge copy is stale
  4. Version the object key, such as app-v2.js, so the CDN path itself is new and uncached Correct answer
MCQSEXAM Read explanation

What does setting reserved concurrency on a Lambda function actually do?

  1. It raises the function's default timeout to match the reserved concurrency value in seconds
  2. It provisions dedicated EC2 capacity that is billed whether or not it is invoked
  3. It carves out and caps concurrency for that function, throttling it beyond the limit Correct answer
  4. It guarantees the function never cold-starts, by keeping the reserved pool warm
MCQSEXAM Read explanation

A consumer receives an SQS message, then its visibility timeout expires before it is deleted. What happens next?

  1. The message stays invisible until the queue's retention period eventually expires
  2. The message becomes visible again and another consumer may process it a second time Correct answer
  3. The message is permanently deleted, because the expired timeout counts as an acknowledgement
  4. The message moves to the dead-letter queue immediately, since the receive has failed
MCQSEXAM Read explanation

An object archived to S3 Glacier Flexible Retrieval must be readable within minutes. Which retrieval tier applies and how is it priced?

  1. Instant, which is the only tier available to Glacier Flexible Retrieval archive objects
  2. Expedited, which typically returns data in 1-5 minutes and is the most expensive tier Correct answer
  3. Bulk, which returns data within 5-12 hours and is the cheapest of the available tiers
  4. Standard, which returns data in 3-5 hours and costs the same as expedited retrieval
MCQSEXAM Read explanation

How does an RDS Multi-AZ standby differ from a read replica in normal operation?

  1. Both are synchronous copies, but only the standby can serve read queries under load
  2. Both are asynchronous copies, and either can be promoted to primary without any data loss at all
  3. The standby is synchronous and not readable, while a replica is asynchronous and queryable Correct answer
  4. The standby is asynchronous and readable, while a replica is synchronous and write-only
MCQSEXAM Read explanation