Answer: Both wait for the Promise. await pauses the async function and resumes with the fulfilled value or throws on rejection. then registers a callback without using throw.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: What is the difference between `fn().then(handler)` and `await fn()` inside an async function?

Solution: await is syntax over Promises. Unhandled rejection vs try/catch is the practical difference.


Answer: The Promise caches one settlement. Additional then-handlers observe it; they do not restart the executor.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Code does `promise.then(ok); promise.then(alsoOk)` expecting the executor to run twice. Why does the network request still happen once?

Solution: To start work twice, call the factory twice. Sharing one Promise is how you join waiters.


Answer: 5

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: What is the mean of 2, 4, 6, 8?

Solution: (2+4+6+8)/4 = 20/4 = 5.


Answer: The 99 pulls the mean up. The median 73 sits with the cluster of typical scores.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A class scored 70, 72, 74, 99. Why is the median a better 'typical score' headline than the mean?

Solution: Mean=(70+72+74+99)/4=78.75. Sorted median is average of 72 and 74 = 73.


Answer: 18

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: An arithmetic sequence has first term 3 and common difference 5. What is the 4th term?

Solution: a_n = a_1 + (n-1)d = 3 + 3*5 = 18.


Answer: 4

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A geometric series has first term 2 and ratio 1/2. What is the infinite sum, if it exists?

Solution: For |r|<1, S=a/(1-r)=2/(1-1/2)=4.


Answer: 25104

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: How much heat in joules raises 2 kg of water by 3 K if c=4184 J/(kg·K)?

Solution: Q=mcΔT=2*4184*3=25104 J.


Answer: Metal conducts heat to your hand faster. Temperature can match; heat flow (conductivity) differs.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why does a metal spoon in hot tea feel hotter than a wooden one at the same temperature after a minute?

Solution: Thermal conductivity, not a different thermometer reading of the bulk tea, explains the sensation.


Answer: 20

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A converging lens has focal length 10 cm. A real object is 20 cm from the lens. Using 1/f = 1/v + 1/u with positive object and image distances, what is the image distance v in cm?

Solution: 1/10 = 1/v + 1/20, so 1/v = 1/10 - 1/20 = 1/20, hence v = 20.


Answer: Distant objects sit beyond 2f, producing a real inverted image. Nearby text inside f produces a virtual upright image that the eye can focus.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why does a magnifying glass form a real inverted image of a distant window on a card, but a virtual upright image of nearby text for your eye?

Solution: Object distance relative to focal length switches the image type. Same lens, different u.


Answer: 1/4

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Both parents are heterozygous Aa for a dominant trait. What fraction of offspring are expected aa?

Solution: Punnett: AA, Aa, Aa, aa. One of four is aa.


Answer: Carriers (heterozygotes) do not show the recessive trait, so affected children can be born to unaffected parents.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why does a recessive disease skip generations in a pedigree more often than a dominant one?

Solution: Dominant traits appear whenever one copy is present, so they show in every generation they are transmitted (with complete penetrance).


Answer: Each insert/update/delete must maintain the index structure in addition to the heap/table row.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why can an index make writes slower even when it makes some reads faster?

Solution: Indexes are extra data. Point lookups win; bulk loads and high-churn tables pay the maintenance.


Answer: AttributeError: the instance never received x. Parent initialization did not run.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A subclass forgets to call super().__init__ and then uses self.x set only in the parent __init__. What happens on the first use of self.x?

Solution: Call super().__init__ (or duplicate the required setup) before using inherited attributes.


Answer: 5

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A rectangle's length is 3 more than its width. Perimeter is 26. What is the width?

Solution: 2(w+3)+2w=26 => 4w+6=26 => 4w=20 => w=5.


Answer: Return passes the object reference. Caller and callee can share the same mutable list.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why does returning a list from a function not copy it unless you copy explicitly?

Solution: If isolation is required, return list(xs) or xs.copy(). Immutables cannot be mutated in place.


Answer: 3

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A singly linked list has 4 nodes. How many next-pointer follows, starting at the head, reach the last node?

Solution: From the first node you take 3 hops to the fourth.


Answer: 3

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: After `x = 3; y = x; x = 4`, what is y?

Solution: y still refers to the int 3. Rebinding x does not rebind y.


Answer: The right-hand side is fully evaluated (as a tuple) before any assignment.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why can `a, b = b, a` swap two names without a temporary in Python?

Solution: Both b and a are read first. Then the names are rebound. A staggered a=b; b=a would lose a value.


Answer: `/` is true division (float). `//` is floor division for ints.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A learner writes `avg = total / count` when both are ints and is surprised in Python 3 vs a C mental model of truncating. What does Python 3 `/` do, and which operator truncates toward zero for ints?

Solution: 7/2 is 3.5. 7//2 is 3. Mixing C's / with Python 3 is a common porting bug.


Answer: 2; bool is a subclass of int, True==1.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: What is `True + True` in Python, and why is that legal?

Solution: Boolean values participate in integer arithmetic. Prefer explicit int() if the intent is numeric.


Answer: Later elif/else bodies are skipped; only one branch of the chain runs.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: What does `elif` mean relative to a chain of `if`s, if the first `if` already matched?

Solution: elif is exclusive with prior matches. Separate ifs can all run.


Answer: Empty lists are falsy; the length form is noisier and still wrong if xs could be None (TypeError).

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why is `if xs:` preferred over `if len(xs) > 0:` for a possibly-None container you already know is a list?

Solution: Truthiness of containers is the idiomatic emptiness test. Guard None separately if needed.


Answer: Mutating a list while iterating shifts later items into the current index, so they are never visited.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A loop `for x in xs: xs.remove(x)` skips elements. Why?

Solution: Iterate a copy, or build a new list, or walk indices from the end.


Answer: 3 times: 2, 5, 8

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: How many times does `for i in range(2, 10, 3):` run, and what values of i?

Solution: Start 2, step 3, stop before 10.


Answer: print writes to stdout and the function still returns None by default.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A function uses `print(total)` instead of `return total`. A caller `x = compute()` gets None. Why?

Solution: Return the value. Printing is a side effect, not a result.


Answer: The parameter binds to the same object; a copy costs time and memory without changing read-only use.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why pass a large list into a function rather than copying it, if the function only reads?

Solution: If the function might mutate, pass a copy or use a tuple.


Answer: TypeError; lists are unhashable so they cannot be dict keys.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: `d = {}; d[ [1,2] ] = 3` raises. What exception class and why?

Solution: Use a tuple (1, 2) if the pair is the key.


Answer: {1, 2, 3}

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: What is `{1, 2, 2, 3}` after construction?

Solution: Sets drop duplicates. Display order is not a contract.


Answer: id is a class attribute; self.id lookup finds the shared list unless rebound on the instance.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A class sets `id = []` in the class body. Instances append to `self.id`. Why do they share one list?

Solution: Create a new list in __init__ as an instance attribute.


Answer: yes

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Does `finally` run if `except` re-raises? Yes or no.

Solution: finally runs on the way out, including when an exception propagates.


Answer: It hides unexpected bugs and can swallow programming errors you wanted to crash on.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why is catching Exception around a whole request handler often worse than catching a specific parse error?

Solution: Catch the recoverable type near the source. Let unknown errors surface.


Answer: sys.modules caches the module; from-import binds names once. Reloading is not automatic.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why can `from pkg import util` and `import pkg.util` bind different objects if util.py mutated after the first import?

Solution: Treat imports as identity of the module object. Avoid mutable module-level state.


Answer: missing

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: What does `next(iter([]), 'missing')` return?

Solution: The default is returned when the iterator is exhausted immediately.


Answer: zip is lazy. A second iteration is empty unless you materialize or tee.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why is `zip(a, b)` not a list, and when does that matter?

Solution: Call list(zip(...)) if you need two passes.


Answer: Any nonempty list is truthy, including the wrong contents.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A test asserts `self.assertTrue(xs)` on a list that should equal [1,2]. Why is that a weak test?

Solution: Assert equality with the expected list.


Answer: once per test method

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: unittest: should `setUp` run once per test method or once per class by default?

Solution: setUpClass is the per-class hook. setUp isolates tests.


Answer: Broken precondition; the algorithm's invariant does not hold.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A two-pointer scan assumes a sorted array but the caller passed insertion order. What class of bug is this?

Solution: Sort first if the API allows, or document and reject unsorted input.


Answer: Theta(log n)

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: In a binary heap of n items, what is Theta of sift-down from the root in the worst case?

Solution: The height of a binary heap is Theta(log n).


Answer: pop(0) is O(n); deque popleft is O(1).

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: When is a deque a better queue than a list using pop(0)?

Solution: Lists are arrays. Deques are designed for ends.


Answer: If size is even, even keys all share one residue class modulo 2, and doubling can preserve a bad modulus.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A hash table resizes at load 2/3 but the hash is `key % size` with size always even. Why can clustering get worse after resize if keys are even?

Solution: Use a prime table size or a mixing hash, not raw modulo of a structured key.


Answer: O(n log n)

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: You replace an O(n^2) loop with an O(n log n) sort-plus-scan. For n=10^6, which is expected to win, ignoring constants?

Solution: n log n grows slower than n^2. Constants can still matter at small n.


Answer: Each += may copy the growing string, totaling Theta(n^2) characters copied.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A function is O(n) but repeatedly concatenates strings in a loop (`s += chunk`). Why can it still be quadratic in CPython?

Solution: Join a list of chunks, or use a buffer.


Answer: O(log n) vs O(n)

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: What is the maximum recursion depth roughly needed for a balanced binary tree of n nodes versus a linked-list-shaped tree, for a DFS?

Solution: Stack depth tracks tree height. Skewed trees are linear height.


Answer: When input height can be thousands; raising the limit still risks crashing the process.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: When is converting recursion to an explicit stack preferable to sys.setrecursionlimit?

Solution: An explicit stack uses heap memory and is bounded by your checks.


Answer: COUNT(col) is fewer or equal; it skips NULLs. COUNT(*) counts rows.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: `SELECT COUNT(*)` vs `COUNT(col)` when col has NULLs. Which counts fewer rows, and why?

Solution: NULL is not a value of col. COUNT(*) is row cardinality.


Answer: Wrapping the column in a function hides the index; a range predicate on ts can use it.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why can `WHERE year = 2024` be sargable on an indexed year column while `WHERE YEAR(ts)=2024` often is not?

Solution: Write ts >= '2024-01-01' AND ts < '2025-01-01'.


Answer: 307/308 preserve method; converting POST to GET can drop the body and change a write into a read.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A client treats HTTP 301 and 302 the same and changes POST to GET after redirect. Which status is specified to keep the method (in modern practice), and what goes wrong if you always GET?

Solution: Follow redirect rules per status. 301/302 historically mutated to GET in browsers.


Answer: no

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Is HEAD supposed to have a response body? Yes or no.

Solution: HEAD returns the headers a GET would, without the body.


Answer: Stashes are easy to drop, are not first-class history, and do not review well.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why is `git stash` a poor backup compared to a commit on a branch?

Solution: WIP commits on a branch are fetchable, reflogged, and describable.


Answer: It is only in the reflog until garbage-collected; main does not include it.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Detached HEAD after checkout of a tag: you commit, then checkout main. Where did the commit go if you did not create a branch?

Solution: Create a branch at the commit before switching away.


Answer: let is block-scoped per iteration when declared in the loop; var is function-scoped.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why does wrapping a loop body in `{ let i = ... }` change what a later callback sees versus `var`?

Solution: for (let i=...) already creates a fresh binding. var does not.


Answer: live binding

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Does a closure copy primitive values from the outer scope at creation time, or keep a live binding?

Solution: It closes over the variable, not a snapshot, unless you copy explicitly.


Answer: No; it rejects when the first rejection happens (after that promise settles).

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: `Promise.all` on [ok, reject, ok] — does it wait for the last success?

Solution: Use allSettled if you need every outcome.


Answer: When each step depends on the previous result or must not run in parallel.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why is `await` in a loop sometimes required instead of `Promise.all`, even if it is slower?

Solution: Parallelism is incorrect for sequential side effects.


Answer: Reasonable for DAG-like shared ownership of immutable data. A smell if you need Rc<RefCell> everywhere to mutate.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: When is `Rc<T>` a reasonable escape from exclusive ownership, and when is it hiding a design problem?

Solution: Prefer borrowing. Interior mutability plus shared ownership is easy to alias incorrectly.


Answer: no

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Can you have two simultaneous `&mut` to the same local? Yes or no.

Solution: Aliasing XOR mutability: at most one exclusive borrow.


Answer: Range stops after close and drain. Only the sender should close.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why is ranging over a channel a shutdown protocol, and who should close?

Solution: Closing from the receiver races with sends (panic).


Answer: yes

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Buffered channel of size 1: can a send proceed without a receiver waiting yet? Yes or no.

Solution: The buffer holds one value. Unbuffered send always synchronizes.


Answer: 9

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A recipe for 4 people uses 6 eggs. How many eggs for 6 people, scaling linearly?


Answer: Subtraction is left-associative; 16-8-2 = (16-8)-2 = 6.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A student computes 16-8-2 as 16-(8-2)=10. What went wrong?

Solution: Parentheses changed the meaning. Write (16-8)-2 or 16-8-2 consistently.


Answer: 8

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Solve 2(x-3)=10. What is x?

Solution: x-3=5, x=8.


Answer: The middle term -6x; (x-3)^2 = x^2-6x+9.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Expanding (x-3)^2 a student writes x^2-9. What term was dropped?

Solution: FOIL or (a-b)^2=a^2-2ab+b^2.


Answer: 19

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: If f(x)=2x+1 and g(x)=x^2, what is f(g(3))?

Solution: g(3)=9, f(9)=19.


Answer: Composition is not pointwise multiplication.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A student computes (f ∘ g)(x) as f(x)*g(x). Name the error.

Solution: (f ∘ g)(x)=f(g(x)). Product is a different operation.


Answer: 12

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: d/dx of x^3 at x=2?

Solution: 3x^2 at 2 is 12.


Answer: The derivative of a constant is 0.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A student says the derivative of a constant 7 is 7. Correction?

Solution: Slope of a horizontal line is zero. 7 is the function value, not the slope.


Answer: They computed circumference; area is 16*pi.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Someone uses area=2πr for a circle of radius 4. What quantity did they compute instead, and what is the area in terms of pi?

Solution: C=2πr, A=πr^2=16π.


Answer: SSA is not a congruence theorem; two triangles can share SSA data and not be congruent (ambiguous case).

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why does SSS congruence not need a separate 'SSA' twin in Euclidean geometry?

Solution: SSS uniquely determines a triangle up to congruence. SSA does not.


Answer: The student mixed degree measure with a radian-mode evaluation.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: sin(30°) is computed as 0.5 but the calculator was in radians. What goes wrong conceptually?

Solution: sin(30 rad) is not 1/2. Convert or switch mode.


Answer: 5/13

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A right triangle has opposite 5 and hypotenuse 13. What is sin of that angle as a reduced fraction?


Answer: 10^2 = 100; order matters and repetition is allowed.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Counting passwords of length 2 from 10 symbols with repetition, a student uses C(10,2). What should they use?

Solution: C(10,2) is unordered distinct pairs.


Answer: 10

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: How many edges in K_5, the complete graph on 5 vertices?


Answer: 1/4

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Two fair coins. A student says P(two heads)=1/3 because HH,HT,TH 'wait they listed TT too' — they listed HH, HT, TT and dropped TH. What is the real probability?

Solution: Four equally likely outcomes; only HH.


Answer: 0.8

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: P(A)=0.3, P(B)=0.5, disjoint. What is P(A or B)?

Solution: Add when disjoint: 0.3+0.5.


Answer: Always, unless they meant the Schur product; standard AB uses row-column dots.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A student multiplies 2x2 matrices by multiplying matching entries (Hadamard). When is that not matrix multiplication?

Solution: (AB)_{ij}=row i of A dot column j of B.


Answer: [[1, 2], [3, 4]]

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: What is the identity matrix I_2 times [[1,2],[3,4]]?

Solution: IA=A.


Answer: 6

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: gcd(24, 18) is?

Solution: Euclid: 24=1*18+6, 18=3*6+0.


Answer: 15=3*5; odd composites exist.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A student says 15 is prime because it is odd. Correction?

Solution: Primality is about factors, not parity (except 2).


Answer: The mean is pulled by 100; the median 2.5 (or 2/3 depending on convention) is robust.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Data 1, 2, 3, 100. A student reports the mean as a typical value. Why is the median often better here?

Solution: For even n, median is average of the two central values: (2+3)/2=2.5.


Answer: The differences are 3 then 6; it is geometric with ratio 2, not arithmetic.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: An arithmetic sequence 3, 6, 12... a student used a=3, d=3. What is wrong?

Solution: Arithmetic needs constant difference.


Answer: 45

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Geometric: first term 3, ratio 2, 4 terms. Sum?


Answer: Untreated plants grown otherwise the same; growth happens without fertilizer too.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A student 'proves' a fertilizer works by showing treated plants grew. What missing piece is the control?

Solution: Compare to control. Anecdote is not a controlled test.


Answer: Independent replicates capture biological/plot variation, not just instrument jitter.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why is replication more than repeating a measurement on the same plant five times in one minute?

Solution: Pseudoreplication pretends dependent data are independent.


Answer: It keeps constant velocity, which may be zero or nonzero.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A 2 kg object with net force 0 is said to 'stop'. What does Newton actually say?

Solution: F_net=0 means a=0, not v=0.


Answer: 4

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Net force 20 N on 5 kg. Acceleration magnitude?

Solution: a=F/m=4 m/s^2.


Answer: 10

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A student sets mgh = 1/2 mv^2 and cancels m, then uses g=10, h=5, and reports v=10 forgetting the 2. Compute the actual v from v=sqrt(2gh).

Solution: v=sqrt(2*10*5)=sqrt(100)=10. If they dropped the 2 they would get sqrt(50).


Answer: 24

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Work = force times displacement along the force. 8 N through 3 m, parallel. Work in J?

Solution: W=Fd=24 J.


Answer: Series adds; equivalent is 8 ohm.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Two 4 ohm resistors in series are treated as 4 ohm total. Correction and series equivalent?

Solution: Parallel would be 2 ohm. Series 4+4=8.


Answer: 18

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Power P=IV. 3 A through 6 V. Power in W?

Solution: P=18 W.


Answer: 2

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: 2H2 + O2 -> 2H2O. How many moles of O2 are needed for 4 mol H2?

Solution: Ratio H2:O2 is 2:1, so 4 mol H2 need 2 mol O2.


Answer: Atoms of each element, not the count of molecules.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A student conserves mass by counting moles of molecules equal on both sides of 2H2+O2->2H2O (3 vs 2). What should be conserved?

Solution: 4 H atoms and 2 O atoms on both sides.


Answer: 5

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Period 0.2 s. Frequency in Hz?

Solution: f=1/T=5 Hz.


Answer: 49/9

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A student adds two amplitudes 3 and 4 and reports intensity scaled by 7. For coherent in-phase waves, intensity scales with amplitude squared. If amplitude becomes 7, intensity scales by what factor vs amplitude 3?

Solution: I ~ A^2 so (7/3)^2=49/9.


Answer: 6

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Heat and temperature are used interchangeably. Give one sentence distinguishing them, then compute Q=mcΔT for m=2, c=1, ΔT=3 (arbitrary units).

Solution: Temperature is a state; heat is energy transferred. Q=2*1*3=6.


Answer: 20

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Thin lens: f=10 cm, object at 20 cm. Image distance v from 1/f=1/v+1/u with u=20. What is v in cm?

Solution: 1/10=1/v+1/20 => 1/v=1/20 => v=20.


Answer: negative

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A student treats a diverging lens like a converging one with positive f in the same sign convention without flipping f. What sign should f have for a diverging lens in the common Cartesian convention used in many intro courses?

Solution: Diverging lenses have negative focal length in that convention.


Answer: 1/4

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: AaBb x aabb independent assortment. What fraction of offspring are aabb?

Solution: Each locus is a testcross 1/2 recessive; 1/2 * 1/2 = 1/4.


Answer: [0, 4]

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: What list does `[n*n for n in range(4) if n%2==0]` produce?

Solution: n=0 and n=2.


Answer: Comprehensions hide side effects; a for-loop makes the I/O obvious and easier to handle errors.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why is a list comprehension a bad place to call a function that writes to disk for each item?

Solution: Use comprehensions for pure mapping/filtering.


Answer: It becomes the wrapper's name, not the original function's.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Without functools.wraps, what happens to `fn.__name__` after `@decorator`?

Solution: wraps copies metadata. Debugging and docs break otherwise.


Answer: yes

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Does `__exit__` run if the with-block raises? Yes or no.

Solution: That is why files still close on error.


Answer: no

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: At runtime, does `def f(x: int)` reject f('a') by itself in stock CPython?

Solution: Annotations are not checked at runtime unless a library does so.


Answer: The default encoding is locale-dependent and can mis-decode bytes.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why pass encoding='utf-8' to open() on Windows for a UTF-8 file?

Solution: Be explicit for portable text I/O.


Answer: BFS; first time you reach the node is a minimum hop count.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: BFS vs DFS for shortest hops on an unweighted graph: which, and why?

Solution: DFS can find a long path first.


Answer: Adjacency lists; matrix is Theta(n^2) entries.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Adjacency matrix vs list for a sparse graph with n=10^5, m=10^5: which stores fewer edge slots, roughly?

Solution: Lists are Theta(n+m).


Answer: Sort by the secondary key first, then stable-sort by the primary key.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: When do you need a stable sort for a two-key sort (sort by last name, then keep first-name order)?

Solution: Unstable primary sort can scramble equal last names.


Answer: Optimal substructure and overlapping subproblems.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: What two properties make a problem a DP candidate?

Solution: Without overlap, divide-and-conquer suffices. Without optimal substructure, greed/DP recurrences fail.


Answer: lost update / race

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Name the bug when two threads do `x = x + 1` on a shared int without a lock.

Solution: Read-modify-write is not atomic. Use a lock or an atomic counter.


Answer: the syscall / trap into the kernel

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: User code calls read(). Who switches to kernel mode, the compiler or the syscall?

Solution: The compiler emits a syscall; the processor exception/syscall instruction enters the kernel.


Answer: it depends

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: A unique index on email: can two rows have NULL email in SQL systems that treat NULL as distinct in unique indexes? Answer: it depends / yes-in-some / never. Pick 'it depends'.

Solution: SQL unique constraints historically allow multiple NULLs; engines differ. Do not assume.


Answer: A composite B-tree is ordered by the leftmost prefix first.

Original Open Reason wording. Do not treat this as a copy of a named course.

Identify the concept
Apply it
State the answer

Prompt: Why can an index on (last, first) serve `WHERE last=?` but not `WHERE first=?` well?

Solution: Leading-column predicates can range-scan. Isolated right columns cannot.


Answer: It binds a second name to the same object. Mutations through either name are visible to both.

Original Open Reason wording. Do not treat this as a copy of the named source.

Name the object
Describe aliasing
Contrast with an explicit copy

Prompt: In Python, why is `b = a` for a list not the same as copying the list?

original curriculum task; not copied from the source

Solution: Assignment copies the reference, not a deep snapshot. Use a slice or copy() when a new list is required.


Answer: 5

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: How many times does `for i in range(5):` run the body?

Solution: range(5) yields 0,1,2,3,4 — five values.


Answer: A single equals is assignment and is a SyntaxError in that position. Use `if score == 100:`.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A learner writes `if score = 100:` expecting a perfect-score branch. What is wrong, and what should they write?

Solution: Comparison uses ==. Assignment is a statement, not a boolean test there.


Answer: A set is unordered (historically). dict keys keep insertion order in modern CPython and are unique.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: You need unique words from a sentence while keeping first-seen order. Why is a set alone not enough in older Python mental models, and what does a dict do here?

Solution: dict.fromkeys(words) then list the keys. Do not sort unless the prompt asks for sorted unique words.


Answer: 4

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: How many numbers does `list(range(1, 8, 2))` contain?


Answer: 6

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A tracing exercise: def add(a,b): return a+b. What is add(add(1,2), 3)?

Solution: Inner add is 3, then 3+3=6.


Answer: Merge sort divides in half each time (log n levels) and merges in linear time per level. Insertion sort may move each new key past all previous keys.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why is merge sort O(n log n) comparisons in the worst case while naive insertion sort is O(n^2)?

Solution: Recurrence T(n)=2T(n/2)+Theta(n) solves to Theta(n log n). Insertion sort's nested scans are Theta(n^2) in the worst case.


Answer: Theta(n log n)

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A loop runs n times; each iteration does a binary search on a sorted array of n items. What is Theta of the comparisons?

Solution: n iterations times Theta(log n) per binary search.


Answer: Every edge has the same cost, so hop-count BFS already finds a shortest path. Dijkstra adds priority-queue overhead without changing the answer.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: You have an unweighted maze on a grid. Why is BFS a better first choice than Dijkstra?

Solution: Dijkstra generalizes BFS to nonnegative weights. Uniform weights make the extra machinery unnecessary.


Answer: 4

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Mergesort split of n=8: how many elements in each half after one even split?

Solution: Even n splits into n/2 and n/2.


Answer: A node may be processed before its predecessors, so subproblems are incomplete.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A DP table for shortest paths is filled in random node order on a DAG. What can go wrong?

Solution: Process in topological order (or relax like Bellman-Ford).


Answer: The local array's storage ends when the function returns, so the pointer is dangling.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why can a C function returning a pointer to a local array be incorrect even if it compiles?

Solution: Automatic storage is reclaimed at return. Callers need heap allocation, a caller-owned buffer, or a static object with documented lifetime.


Answer: Buffer overflow / missing terminator. strlen+1 bytes are required for a C string.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A C program mallocs a buffer, copies a string without room for the NUL, then prints it. Name the defect class and the missing byte.

Solution: C strings are NUL-terminated. strncpy without an explicit terminator is a common miss.


Answer: fopen returns NULL on failure (missing file, permissions). Using the pointer is undefined.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why must you check fopen's return before fread, even if the path 'looks right'?

Solution: I/O can fail. Always branch on NULL and inspect errno or perror.


Answer: The process may never exit; the leak grows with requests.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why is forgetting to free a heap buffer in a long-running C server a problem even if the OS will reclaim memory at exit?

Solution: Match malloc/free on the request path. Exit reclamation does not help a daemon.


Answer: No; POSIX text files may omit the final newline. Handle both.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A C program reads a file with `while(fgets)` and treats a missing newline on the last line as a bug. Is it?

Solution: Do not require a newline to accept the last record.


Answer: 5

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Solve 3x - 6 = 9.

Solution: 3x = 15, so x = 5.


Answer: 28

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A linear cost is C(n)=4n+12. What is the cost of 7 extra items relative to 0 items?

Solution: C(7)-C(0)=40-12=28. The intercept cancels; only the slope times 7 remains.


Answer: 15

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: The first three triangular numbers are 1, 3, 6. What is the 5th?

Solution: T_n = n(n+1)/2. T_5=15.


Answer: 4

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Solve 5x = 20. x=?

Solution: Divide both sides by 5.


Answer: 81

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A square has perimeter 36. What is the area?

Solution: Side 9, area 81.


Answer: A historical language quirk. Test with `value === null`.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why does `typeof null === 'object'` in JavaScript, and what should you use instead to test for null?

Solution: Early JavaScript used a type tag that made null look like an object. Strict equality against null is the reliable check.


Answer: fetch only rejects on network failure. HTTP 404 is a fulfilled Promise with ok=false. Check r.ok or r.status.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why does `fetch(url).then(r => r.json()).then(data => data)` still need error handling for HTTP 404?

Solution: Treat non-2xx as an application error. catch() does not see them unless you throw.


Answer: var is function-scoped, so every handler shares one i. Use let, or pass i into a factory.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: An event handler is added inside a loop with `var i` and later logs i. Why is it the last i, and what binding fixes it?

Solution: let creates a per-iteration binding. Closures capture bindings, not snapshots of numbers.


Answer: fetch only rejects on network failure; HTTP 404 is still a resolved Response.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: fetch().then(r => r.json()).then(use) with no catch: a 404 still hits use() with a body. Why?

Solution: Check r.ok before json().


Answer: GET

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Which method is defined as safe: GET or POST?

Solution: GET should not have side effects. POST is for non-idempotent writes.


Answer: Revert records a new commit that undoes a change. Reset moves the branch pointer and can rewrite history others already pulled.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: What does `git revert` do that `git reset --hard` does not, and when is revert safer on a shared branch?

Solution: On shared branches, prefer revert so collaborators keep a linear, fetchable history.


Answer: The secret remains in git history and clones. Rotate the credential; history rewrite only helps unpushed or coordinated force-push, which still leaks if others fetched.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: You committed a secret to main and pushed. Why is deleting the file in a new commit not enough, and what must you still do?

Solution: Treat leaked secrets as compromised. git rm does not unsay old blobs.


Answer: JavaScript on the page can read a non-HttpOnly cookie, so XSS can steal the session. HttpOnly hides it from document.cookie.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why is storing a session identifier in a non-HttpOnly cookie riskier than an HttpOnly cookie?

Solution: HttpOnly is not a complete XSS defense, but it removes one theft path. Still validate and encode output.


Answer: count is in the lexical environment, not a property of the returned object.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A module pattern returns {inc} that closes over count. Why can callers not assign count directly?

Solution: Only the exported functions see count. That is encapsulation via closure.


Answer: Query strings land in logs, history, and Referer; POST body is not in the URL.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A form uses GET and puts a password in the query string. Name one reason POST to HTTPS is preferred.

Solution: Still use TLS. GET is also cached and bookmarked.


Answer: An iterable can produce an iterator via iter(). An iterator is the object that yields values via next() and is spent as you consume it.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: What is the difference between a Python iterable and an iterator?

Solution: Lists are iterable but not themselves iterators. iter(xs) returns an iterator. for-loops call iter() for you.


Answer: Bare except catches BaseException subclasses used for control flow. Catch ValueError for int().

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why can `except:` hide a KeyboardInterrupt, and what should you catch instead when parsing integers?

Solution: Use except ValueError. Let KeyboardInterrupt and SystemExit propagate.


Answer: It uses __all__ if present, else public names. It pollutes the importer's namespace and hides origins.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: What does `from package import *` use to decide names, and why is it risky in libraries?

Solution: Prefer explicit imports in library code. Star imports are a convenience for interactive sessions.


Answer: {'a': 2}

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: What does `{k: v for k, v in [('a', 1), ('a', 2)]}` evaluate to, and why is there one key?

Solution: Dict displays last-write-wins for duplicate keys. The second pair overwrites.


Answer: If read raises, close is skipped. with always runs __exit__.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why is `f = open(path); data = f.read(); f.close()` weaker than a with-block when read() can raise?

Solution: try/finally is the manual equivalent. with is the standard spelling.


Answer: `list` says it is a list. `list[int]` additionally says checkers should expect integer elements.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: What is the difference between `list` and `list[int]` in a function annotation?

Solution: CPython does not enforce the parameter. Type checkers do.


Answer: 0

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: dict.fromkeys(['a','b'], 0) maps both keys to what value?

Solution: fromkeys uses a shared default value.


Answer: It returns [] because there are no rows to zip; *[] is no arguments to zip.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: `list(zip(*[]))` — what happens, and why is unzipping an empty list a corner case?

Solution: zip() with no iterables yields empty. Guard empty matrices before unzip.


Answer: To prevent data races and iterator invalidation at compile time: readers may share, a writer must be exclusive.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: In Rust, why can you have many immutable references or one mutable reference, but not both at once for the same value?

Solution: The borrow checker encodes this aliasing rule. Mixing &T and &mut T to the same place is rejected.


Answer: Clone when you truly need two owned values. It is a smell if a borrow or restructuring would have been enough.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: When would you clone a String to satisfy the borrow checker, and when is that a design smell?

Solution: Clones allocate. Prefer &str, lifetimes, or moving once.


Answer: push needs &mut self. An outstanding &T borrow forbids &mut T. End the immutable borrow first, or don't hold it across the mutation.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: You hold an immutable borrow of a Vec and try to push. Why does that fail, and what API change would make the intent legal?

Solution: NLL still cannot allow aliased mutation. Split the scopes.


Answer: yes

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Is i32 Copy? Yes or no.

Solution: Integer types implement Copy, so assignment does not move them.


Answer: No; Vec assignment moves. Clone is explicit.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why does Vec<String> move on assignment while Vec<i32> copies the vector header but still moves heap buffers... actually Vec is not Copy. Correct the misconception: does assigning a Vec clone the elements?

Solution: Neither Vec<T> is Copy. Move transfers the pointer. clone() deep-copies.


Answer: Close signals no more sends. Further sends are programmer errors. Receives drain remaining values then zeros so range loops terminate.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why is sending on a closed Go channel a panic, while receiving from a closed channel yields the zero value?

Solution: Use close only from the sender. Check the two-value receive form to distinguish a zero value from a closed channel.


Answer: Close is a signal from senders that no more values will be sent. Receivers closing can panic senders still sending.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why should you not close a channel from the receiver side in a typical worker pool?

Solution: Sender closes; receivers range until close. Coordinate shutdown with WaitGroup and a done channel if needed.


Answer: Deadlock: the same goroutine waits for a lock it already holds. Do not call user callbacks while holding the lock, or use a documented reentrant design (not standard mutex).

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A function locks a mutex, then calls a callback that tries to lock the same mutex. What happens with a non-reentrant mutex, and how do you avoid it?

Solution: Keep critical sections small. Copy data, unlock, then callback.


Answer: no

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Does `go f()` wait for f to finish before the next statement? Yes or no.

Solution: It starts a goroutine. Wait with channels or WaitGroup.


Answer: Concurrent map writes are undefined / can panic.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A map is written from two goroutines without sync. What is the specified risk?

Solution: Use a mutex or sync.Map as documented. Do not race on maps.


Answer: Placeholders disappear and are not a reliable accessible name. Labels persist for assistive technology and visual users.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why should a form control that is required also have an accessible name, not only a placeholder?

Solution: Associate a label via for/id or wrapping. Required is independent of naming.


Answer: A div is not a form-associated submit control, is not keyboard-activated by default, and lacks button semantics for assistive tech.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why is `div` with a click handler a poor substitute for a `button` that submits a form?

Solution: Use button type=submit. If you must use another element, you must reconstruct keyboard, role, and form behavior.


Answer: The label can point at that control, so clicking the label focuses/activates it and assistive tech can name it.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: What does a unique `id` on a page enable for a label's `for` attribute?

Solution: Duplicate ids break the association. One id per document.


Answer: yes

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: In HTML, is `<img>` a void element that must not have a closing tag in HTML syntax? Yes or no.

Solution: Void elements have no content. XML/XHTML differs; this item is HTML.


Answer: The HTML is delivered to the client; anyone can read the source.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why is putting a secret in a data-* attribute on a public page still a leak?

Solution: Secrets belong on the server, not in markup.


Answer: It becomes an alias for the rowid, so lookups and inserts use the table's implicit row identity.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: In SQLite, why is `INTEGER PRIMARY KEY` special compared with a non-integer primary key?

Solution: WITHOUT ROWID tables are the exception. Otherwise INTEGER PRIMARY KEY is the rowid.


Answer: The OR means rows matching only y still qualify, so an index on x cannot find them. Often you need a second index or a UNION of two index lookups.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why can `SELECT * FROM t WHERE x = 1 OR y = 2` be hard to index well with a single B-tree on (x)?

Solution: OR across different columns fights a single-column index. AND of indexed prefixes is easier.


Answer: 3

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: In SQLite, what does COUNT(*) return on a table with 3 rows including one all-NULL row?

Solution: COUNT(*) counts rows, not non-NULL values. COUNT(column) would skip NULLs in that column.


Answer: real

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: SQLite: SELECT typeof(1.5); what type name?

Solution: Floating values are REAL affinity/storage.


Answer: A leading wildcard prevents a left-to-right index prefix match.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why might `WHERE name LIKE '%son'` not use a normal B-tree index on name?

Solution: LIKE 'son%' can use the index; '%son' generally cannot.


Answer: It holds a snapshot so statements in the same transaction see a stable view and avoid non-repeatable reads of committed updates.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: What does REPEATABLE READ prevent in PostgreSQL that READ COMMITTED does not?

Solution: READ COMMITTED takes a new snapshot per statement. Repeatable read keeps one snapshot until commit or rollback. Write conflicts can still abort the transaction.


Answer: Random I/O into most of the heap can be slower than one sequential read. Selectivity is too low for the index to win.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why might a sequential scan beat an index on a query that matches 90% of a table?

Solution: Indexes help selective predicates. The planner compares costs; high match rate favors seq scan.


Answer: The index contains all columns the query needs, so PostgreSQL can avoid heap fetches when visibility allows.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: What is a covering index in PostgreSQL terms (Index Only Scan), and what extra data makes it possible?

Solution: INCLUDE columns or a matching btree of selected columns. VACUUM/visibility maps still matter.


Answer: unknown

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: NULL AND TRUE in SQL three-valued logic is what: true, false, or unknown?

Solution: AND with unknown and true is unknown.


Answer: NULL = NULL is unknown, not true. Use IS NULL.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A unique constraint allows two NULLs in some SQL systems. Why is `WHERE email = NULL` still wrong to find them?

Solution: Three-valued logic. Equality is not a null test.


Answer: write can transfer fewer bytes than requested. The caller must loop on the remainder or treat a short write as an error.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why must a program check the return value of `write()` instead of assuming the full buffer was written?

Solution: Signals, pipes, and device limits can produce short writes. POSIX does not guarantee a full transfer in one call.


Answer: The allocator may not find a large enough contiguous region (or hit limits). Check for NULL before writing.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why can `malloc` returning NULL be more likely after a huge allocation than a 16-byte one, and what must the caller do?

Solution: OOM is a normal failure. Dereferencing NULL is not.


Answer: gets cannot bound the write. Any longer line overruns the buffer. Use fgets or similar with a size.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A program uses `gets` to read a line. Why is that always a defect even if the input 'is usually short'?

Solution: Unbounded C string APIs are unsafe. Size belongs in the API.


Answer: no

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Does a successful write() guarantee the data is on durable storage? Yes or no.

Solution: It may sit in page cache until fsync/fdatasync or equivalent.


Answer: printf may itself fail or succeed and change errno.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why can `errno` after a failed libc call be overwritten if you printf before checking it?

Solution: Save errno immediately, then log.


Answer: 2

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A spacecraft of mass 800 kg feels 1600 N of net thrust. What is the acceleration in m/s^2?

Solution: a = F/m = 1600/800 = 2.


Answer: 50

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A 4 kg probe moves at 5 m/s. What is its kinetic energy in joules?

Solution: KE=1/2 m v^2 = 0.5*4*25=50.


Answer: No net force means constant velocity. Thrust was needed to change speed, not to keep moving.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: In deep space with negligible gravity, why does a spacecraft keep moving after the engine cuts off?

Solution: Newton's first law. Drag is what makes Earth intuition different.


Answer: 11314

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Using v=sqrt(2gR) with g=10 m/s2 and R=6.4e6 m, what is v rounded to the nearest integer m/s?

Solution: 2gR=1.28e8; sqrt(1.28e8)≈11313.71, which rounds to 11314.


Answer: A normal is a long-run statistical baseline. A forecast is a short-range prediction of a specific state.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why is a 30-year climate normal not the same thing as tomorrow's weather forecast?

Solution: Climate describes distributions over decades. Weather is the atmosphere's state at a time and place.


Answer: The mean would silently omit the storm surge days. Missingness is information, not a reason to pretend the series is complete.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A coastal sensor fails for three days during a storm. Why must a monthly mean sea-level plot disclose that gap?

Solution: Document coverage. Imputation is a separate, declared step.


Answer: 2

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A water wave has period 4 s and wavelength 8 m. What is the speed in m/s?


Answer: 0.3

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A tide gauge reads 1.2 m, then 1.5 m. What is the delta in metres?


Answer: Magnitude estimates energy at the source. Intensity describes local shaking, which depends on distance, depth, and ground conditions.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why can the magnitude of an earthquake and the intensity felt at a city differ?

Solution: The same magnitude event can be barely felt far away and damaging on soft sediment nearby.


Answer: Different distance/azimuth from the rupture, and different site geology (amplification on sediments vs rock).

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Two seismometers record the same quake with different peak accelerations. Give two non-instrument-failure reasons.

Solution: Intensity is local. Magnitude is a source estimate.


Answer: 100

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A 2 kg rock falls 5 m. Taking g=10 m/s^2 and PE=mgh, what is the loss of gravitational PE in joules?

Solution: mgh=2*10*5=100 J.


Answer: 48000

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A map scale is 1:24000. 2 inches on the map is how many inches on the ground?

Solution: 2*24000=48000 inches.


Answer: Publicly posted is not the same as redistributable. Each resource can carry a different license, including NC or SA terms.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Give one reason an open educational resource still needs its license checked before it enters a dataset.

Solution: Store the exact license, attribution, and permitted use. Do not assume a catalog site's presence is a grant.


Answer: No. Informal permission is not a clear redistribution license. Leave it out or obtain an explicit license.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: A worksheet is labeled 'free to use in class' with no SPDX. Can Open Reason copy it into a CC BY 4.0 dataset?

Solution: Public posting is not CC BY. Ambiguous licenses stay out of the release.


Answer: BY means you must credit the licensor in the manner they request, commercially or not.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why is attribution still required for CC BY even when commercial use is allowed?

Solution: Commercial rights and attribution are separate license axes.


Answer: Copyright still covers the wording; inspiration is original tasks with attribution of influence, not quotation.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: Why is 'inspired by a public syllabus' not a license to copy homework text?

Solution: Open Reason writes original prompts and sets verbatim false.


Answer: Share-alike requires derivatives to use a compatible SA license. Relicensing as non-SA CC BY would break the grant.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: If a textbook is CC BY-SA, why must derived dataset rows keep share-alike instead of being relicensed as CC BY 4.0?

Solution: Keep the original SPDX on those rows or exclude them from a CC BY-only release.


Answer: A close adaptation can still be a derivative. SA follows derivatives. If unsure, do not include it in a non-SA corpus.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: You rewrite a CC BY-SA paragraph in your own words but keep the same examples and structure. Why might share-alike still attach?

Solution: Paraphrase is not a clean room. Original tasks with independent examples avoid the issue.


Answer: The combination must be released under a license the originals permit for derivatives, usually the same SA family.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: What does 'compatible share-alike' mean when combining two SA works?

Solution: You cannot wash SA off by mixing with CC BY-only text in one redistributed unit.


Answer: A close paraphrase can still be a derivative work under SA terms.

Original Open Reason wording. Do not treat this as a copy of the named source.

Read the prompt
Apply the concept
State the answer

Prompt: If you paraphrase a CC BY-SA chapter into a dataset row, why might share-alike still attach?

Solution: Write original problems. Do not relicense SA text as CC BY 4.0.