Build reusable numeric transformations. Values and factors are integers or floats; tests use exactly representable results.

Prototype: scale(value, factor=2) returns value * factor. Accept the factor either positionally or by keyword.

Final: transform_values(values, operation, *, keep=None) returns a new list. For each input, call keep(value) first if a predicate was supplied. Skip values for which it is false. Apply operation(value) exactly once to every retained value and preserve order. With no predicate, retain every value. Example: transform_values([1, 2, 3], lambda n: n * 10, keep=lambda n: n > 1) -> [20, 30]. Empty input returns []. Do not mutate the input. Let callback exceptions propagate. keep must be passed by keyword.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.