2025 Jan OPPE 2 - Set 2¶
Extract Middle Elements from a List
Return the middle element (odd length) or two middle elements (even length) as a list. Covers n//2 indexing, parity check, and the slicing shorthand lst[start:mid+1].
Shuffle a Three-Word Sentence
Rearrange words in a sentence using a 0-based index tuple. Covers split(), indexing by tuple order, and " ".join().
Check If Both Numbers Have the Same Sign
Return True if both numbers are strictly positive, both strictly negative, or both zero. Covers the three-case sign check and why zero is its own category.
SolvedCheck Palindrome (Advanced)
Palindrome check ignoring spaces, punctuation, and case. Covers str.isalnum(), c.lower(), and cleaned[::-1]. Also notes a problem statement error in the examples.
Abbreviate Initials and Sort (Last, F.M. Format)
Convert full names to "Last, F.M." format and print sorted. Full I/O - covers "".join() for no-space initials and surname-first formatting.
Employee Task Analysis
Four operations on employee records - total tasks, most efficient employee, sort by hours, productive members. Covers negated tuple keys for descending sort and efficiency ratio tie-breaking.
SolvedSimple Stemmer
Strip the first matching suffix from each word in a file, preserving line structure. File I/O → stdout - covers first-match-wins suffix scanning, next() pattern, and blank line handling.