Skip to content

2025 May OPPE 2 - Set 2

Section 1 · Question 1

Check Multiple of 5 but Not 3

Return True if a number is divisible by 5 but not 3. Covers num % 5 == 0 and num % 3 != 0, short-circuit and, and Python's non-negative modulo for negatives.

Solved
Section 1 · Question 2

Check for Greeting Prefix

Return True if a string starts with "Hello " or "Hi " (space included). Covers str.startswith() with a tuple argument and the importance of the trailing space.

Solved
Section 1 · Question 3

Combine First and Last Two Characters

Return a string of the first two and last two characters, or "" if length < 4. Covers s[:2], s[-2:], and the overlap pitfall for short strings.

Solved
Section 2 · Question 1

Reversed Squares of List Elements

Return squares of list elements in reverse order. Covers [x**2 for x in reversed(l)], the equivalence of reversing before vs after squaring, and negative number squaring.

Solved
Section 2 · Question 2

Make Word from Last Characters of Qualifying Words

Filter words by minimum length and starting character, collect their last characters. Full I/O - covers two-condition filtering, case-sensitive matching, and empty-line output.

Solved
Section 3 · Question 1

Sales Data Analysis

Four operations on transaction data - total revenue, per-product aggregation, top seller, average price. Covers single-pass aggregation, tuple keys for tie-breaking, and round(total_rev/total_units, 2).

Solved
Section 3 · Question 2

Uppercase Every k-th Vowel in a File

Uppercase every k-th vowel globally across a multi-line file, lowercase all others. File I/O → stdout - covers global vowel counter, ch.lower() in VOWELS, and preserving consonant case.

Solved