2025 May OPPE 2 - Set 3¶
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.
Remove Second and Second-Last Character
Return the string with its second and second-last characters removed.
SolvedAdd 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.
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.
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(...))).
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.
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.