2025 May OPPE 2 - Set 1¶
Compute Electricity Bill
Three-slab billing - flat rate per unit with optional fixed charges. Covers if-elif-else ordering, flat vs tiered billing distinction, and a noted problem statement error for 210 units.
SolvedIs Reverse Combined Palindrome
Reverse the first string, concatenate with the second, check if palindrome. Covers s1[::-1], string concatenation, and combined == combined[::-1].
Pangram Check
Return True if a string contains all 26 letters. Covers set.issubset(), the <= subset operator, all() short-circuiting, and string.ascii_lowercase.
Check for Arithmetic Progression
Verify all consecutive differences are equal. Covers diff = seq[1] - seq[0], all() with range, zip(seq, seq[1:]), and the len(set(diffs)) == 1 trick.
Rotate Matrix Clockwise 90°
Rotate an m×n matrix to n×m by turning columns into rows (bottom to top). Full I/O - covers the zip(*matrix[::-1]) trick and the column-index formula matrix[m-1-i][j].
Book Data Analysis
Five functions on book tuples - short/medium sets, ISBN lookup, language counts, genre+language total. Covers set comprehensions, next(..., None), dict.get(k, 0), and Counter.
File Content Zigzag Shift
Print each character preceded by spaces following a zigzag pattern of width z. File I/O → stdout - covers cycle length 2*(z-1), ascending/descending position formula, and itertools.cycle.