2025 Jan OPPE 2 - Set 1¶
Check if Either Number is a Multiple
Return True if either a is a multiple of b or vice versa. Covers a % b == 0 or b % a == 0 and the symmetric nature of the check.
Starts and Ends with Same Vowel
Return True if a string starts and ends with the same vowel (case-insensitive). Covers s[0].lower(), s[-1].lower(), and why one vowel check is enough.
Rearrange Tuple - Middle Elements to Ends
Place the two middle elements of an even-length tuple at the start and end. Covers middle-index formula n//2-1 and n//2, single-element tuple syntax (x,), and the pop() index-shift trick.
Count Strings with Length Divisible by 3 or 5
Count strings whose length is divisible by 3 or 5. Covers len(s) % 3 == 0 or len(s) % 5 == 0, sum(1 for ...), and summing boolean map results.
Thresholding a 2D Array with * and @
Replace each pixel with @ (≥ threshold) or *. Full I/O - covers ternary expression in a generator, " ".join() for no trailing space, and row-by-row processing.
Railway Ticket Booking Analysis
Four operations on nested booking data - ticket prices, total revenue, berth preference counts, coach type counts. Covers pre-initialising with zeros, None as a dict key, and ticket_rate × passengers.
String Rearrangement
Rearrange each string's characters using 1-based index instructions from a file. File I/O → stdout - covers parts[0] vs parts[1:], 1-to-0 index conversion, and blank line guarding.