Skip to content

2025 May OPPE 2 - Set 3

Section 1 · Question 1

Three-Digit Number with Digit-Sum Divisible by k

Return True if a number is 100–999 and its digit sum is divisible by k. Covers range check, sum(int(d) for d in str(n)), and arithmetic digit extraction.

Solved
Section 1 · Question 2

Remove Second and Second-Last Character

Return the string with its second and second-last characters removed.

Solved
Section 1 · Question 3

Add Average Key with Absolute Difference Value

Insert a new entry into a dict in-place - key is the rounded average of two existing keys, value is the absolute difference of their values. Covers round(), abs(), and in-place mutation.

Solved
Section 2 · Question 1

Count Words with Matching First/Last but Different Second/Second-Last

Count words satisfying two case-insensitive conditions. Covers w[0]==w[-1], w[1]!=w[-2], and lowercasing the whole word upfront.

Solved
Section 2 · Question 2

Remainder Grouping Dictionary

Group numbers by their remainder mod k, print sorted groups. Full I/O - covers x.strip() for comma-separated input, setdefault grouping, and ",".join(map(str, sorted(...))).

Solved
Section 3 · Question 1

Book Reading List Data Analysis

Four operations on book records - average rating, average pages, longest book, above-average books. Covers computing averages upfront, tuple key tie-breaking, and strict > filtering into a set.

Solved
Section 3 · Question 2

Column Totals in a Markdown Table

Parse a markdown table from a file and print column sums. File I/O → stdout - covers the four-step row parser (strip → strip("|") → split("|") → strip cells), skipping the separator, and zip(*rows) transpose.

Solved