A score-processing library constructs new functions using the Python code below. Select every true statement about the resulting functions and their evaluation.
def compose(first, second): def combined(x): return second(first(x)) return combined def increase(x): return x + 3 def square(x): return x * x forward = compose(increase, square) reverse = compose(square, increase)
The expression compose(increase, square) calls increase before returning its result.
The expression compose(increase, increase)(2) returns the numeric value 8.
The expression compose(forward, reverse)(2) returns the numeric value 628.
The expression compose(reverse, forward)(2) returns the numeric value 52.
Unlock full course notes by signing up
Return behavior for a later call
A game needs make_adjustment(delta) to return a reusable function that adds delta to a score supplied later. The final outer return statement is missing from this Python code:
Complete that statement by supplying only the function's identifier: return ________.
Dispatch jobs with tied sorting keys
A dispatch program orders jobs by urgency using the Python code below. Each pair contains a job label followed by its integer urgency level.
A key function returns the value that a sorting utility uses to order each item. Python’s sorted places smaller keys first, and jobs with equal keys retain their original input order.
Complete the table with each job’s returned key and its position in ordered_jobs, counting the first position as 1. Enter exact integers in every blank.
Merge chunk summaries without changing behavior
An event-processing program computes an integer summary using a reduction, which combines successive values into one running result through a supplied callback.
The first slice contains the first three codes, and the second contains the last two. A developer proposes replacing the sequential computation with separately computed chunk summaries.
Find whole and naive. Then find the constant multiplier w such that w * left + right reproduces the sequential result for every possible choice of integer codes with these same chunk lengths. Enter all three answers as exact, unitless integers.