Answer: b still refers to [1, 2]. Rebinding a does not mutate or rebind b.

Do not treat assignment as always copying.

Identify the objects
Track which names are rebound
State b's referent

Prompt: A learner writes `a = [1, 2]; b = a; a = [3]`. Explain whether `b` changes, using name-binding rather than a box metaphor.

Solution: `a = [1, 2]` binds the name `a` to a list object. `b = a` binds `b` to that same object. `a = [3]` creates a new list and rebinds only `a`. `b` still refers to `[1, 2]`.


Answer: [0, 1, 2, 3]

Recall range(n)
List the integers
Explain the missing endpoint

Prompt: What does `list(range(4))` evaluate to, and why is 4 missing?

Solution: range(n) is a half-open interval [0, n). The endpoint n is excluded, matching valid indices of a length-n sequence.


Answer: The default list is created once at definition time. Use None and create a new list in the body.

Repair must keep the convenient default of an empty list per call.

The unexpected sharing happens across calls with no explicit bucket.

Identify the shared object
Explain definition-time evaluation
State the None pattern

Prompt: A function is defined as `def collect(item, bucket=[]): bucket.append(item); return bucket`. A second call with a new item returns a list containing both items. Diagnose the defect and describe the standard repair.

Solution: Default argument objects are evaluated once. The same list is reused and mutated. Write `def collect(item, bucket=None):` and `if bucket is None: bucket = []`.


Answer: Collisions concentrate keys in one bucket, so lookup walks a chain. Mitigations include randomized hash seeds and treeified buckets.

Stay at data-structure behaviour, not a CVE writeup.

Average-case bounds hide adversarial or highly skewed keys.

State the average-case assumption
Describe collision chains
Name a mitigation

Prompt: Why can a hash table that is O(1) average-case become linear in a single lookup, and name one mitigation used in production runtimes?

Solution: Average-case O(1) assumes a bounded load factor and well-spread hashes. If many keys collide, a bucket degrades to a list (or similar) and that lookup is O(n). CPython randomizes hash seeds and treeifies large colliding dict buckets.


Answer: 14

Do not insert extra parentheses that change meaning.

Apply precedence
Compute the product
Add

Prompt: Evaluate 2 + 3 * 4 using standard arithmetic precedence.

Solution: Multiplication binds first: 3 * 4 = 12, then 2 + 12 = 14.


Answer: -3

Isolate x
Simplify
Check by substitution

Prompt: Solve for x: x + 5 = 2.

Solution: Subtract 5 from both sides: x = 2 - 5 = -3.


Answer: 1

f(0) is undefined.
Nearby values approach 1.

Recognize the indeterminate form
Recall or compute the standard limit
State 1

Prompt: Compute lim_{x -> 0} (sin x)/x. Direct substitution is undefined; still give the limit.

Solution: The two-sided limit is 1. A 0/0 form at a point does not by itself imply the limit is missing.


Answer: It must be testable and potentially falsifiable by observation or experiment.

Do not claim experiments prove hypotheses in the mathematical sense.

Slogans that cannot be tested are not scientific hypotheses.

Define testability
Mention falsifiability
Mention controls

Prompt: What makes a scientific hypothesis different from an untestable slogan?

Solution: A hypothesis is a claim that could fail a well-designed test. Experiments can disconfirm it; they do not provide mathematical proof. Controls and replication matter.


Answer: 4

Assume a particle model and constant mass.

Net force and mass are given in SI units.

Prompt: A net force of 12 N acts on a 3 kg mass. What is the acceleration magnitude in m/s^2?

Solution: Newton's second law: a = F/m = 12/3 = 4 m/s^2.


Answer: b is [1, 2, 3] because a and b referred to the same list. append mutated that object; it did not rebind b.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: After a = [1, 2]; b = a; a.append(3), what is b and why?

Solution: Misconception: A variable is a box that stores a copy of an object forever. Why it is wrong: In Python a name is a binding to an object. Assignment rebinds the name; mutable objects can still change through other names. Correct: Names refer to objects. Assignment of one name to another makes both names refer to the same object. Rebinding one name later does not rebind the other.


Answer: Assignment cannot appear in that expression position; comparison uses two equals signs.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: Why does if n = 1: fail to parse in Python?

Solution: Misconception: if x = 0 is a valid test that checks whether x equals zero. Why it is wrong: In Python a single equals sign is assignment. Equality is written with two equals signs. The assignment form is a SyntaxError. Correct: Use a comparison, not assignment, in a conditional test.


Answer: [0, 1, 2]

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: What values does list(range(3)) produce?

Solution: Misconception: range(n) yields n, so a loop over range(len(xs)) includes the last index twice. Why it is wrong: range(n) yields 0 through n-1, which is exactly the valid indices of a length-n sequence. Correct: Half-open intervals [0, n) match zero-based indexing. The last index is n - 1.


Answer: The same default list is mutated across calls because it is created once at definition time.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: Why can a function with a default empty list return [1, 1] on a second call that appends 1?

Solution: Misconception: A default argument list is created fresh on every call. Why it is wrong: Default argument objects are created once, when the function is defined, and reused. Correct: Use None as the default and create a new list inside the function body.


Answer: [[0, 1]] because the inner list was shared.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: After a = [[0]]; b = a[:]; b[0].append(1), what is a?

Solution: Misconception: Slicing a list always deep-copies nested objects. Why it is wrong: A slice copies the top-level list only. Nested mutables remain shared. Correct: A slice is a shallow copy. Nested lists still alias unless copied recursively.


Answer: 14

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: Evaluate 2 + 3 * 4.

Solution: Misconception: Addition is always done before multiplication, left to right. Why it is wrong: Multiplication and division bind more tightly than addition and subtraction. Correct: Evaluate 2 + 3 * 4 as 2 + 12 = 14, not (2 + 3) * 4.


Answer: -3

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: Solve x + 5 = 2.

Solution: Misconception: Moving a term across an equals sign never changes its sign. Why it is wrong: Adding the additive inverse is required; the sign of the moved term flips. Correct: From x + 3 = 7, subtract 3 from both sides to get x = 4.


Answer: No. The two-sided limit is 1 even though direct substitution is undefined.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: Does lim x->0 of (sin x)/x fail to exist because the expression is 0/0 at 0?

Solution: Misconception: If substituting x=a into f(x) is undefined, the limit cannot exist. Why it is wrong: A limit describes nearby values. A hole or removable discontinuity can still have a finite limit. Correct: Algebraic simplification or a two-sided check can show the limit exists even if f(a) is undefined.


Answer: It must be testable and potentially falsifiable by observation or experiment.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: What would make a hypothesis scientific rather than a slogan?

Solution: Misconception: A hypothesis is an uneducated guess and experiments exist to prove it true. Why it is wrong: A hypothesis is a testable claim. Experiments can falsify it; they do not prove it in the mathematical sense. Correct: Design a test that could fail, collect data, and update confidence. Replication and controls matter.


Answer: It swallows unexpected errors and control-flow exceptions; catch a specific type instead.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: Why is a bare except: considered harmful in Python?

Solution: Misconception: except: is the safest way to keep a program running. Why it is wrong: A bare except catches SystemExit and KeyboardInterrupt and hides unexpected bugs. Correct: Catch the specific exception you can handle. Let the rest propagate.


Answer: Theta(n^2) if work() is constant time.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: What is the time complexity of for i in range(n): for j in range(n): work()?

Solution: Misconception: Two nested loops over n items are always O(n) because each loop is simple. Why it is wrong: Each of n outer iterations does n inner iterations, which is Theta(n^2) work. Correct: Multiply independent nested iteration counts unless the inner bound shrinks.


Answer: It builds a list of None values as a side effect of printing. A for-loop states the intent.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: Why is `[print(x) for x in xs]` a poor pattern?

Solution: Misconception: A list comprehension is the right place to call functions for their side effects. Why it is wrong: Comprehensions exist to build a collection. Side-effecting inside them hides control flow and still allocates a list. Correct: Use a for-loop for actions. Use a comprehension when you need the resulting sequence.


Answer: It is 'inner', not the original function name.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: After decorating without wraps, what is f.__name__ if the wrapper is named inner?

Solution: Misconception: A decorator that returns an inner function automatically copies the original function's name and docstring. Why it is wrong: The inner function has its own __name__ and __doc__ unless you apply functools.wraps. Correct: functools.wraps(func) updates the wrapper's metadata so tools and tests still see the original identity.


Answer: No. CPython will return 'a' unless you add a runtime check.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: Does `def f(x: int) -> int: return x` raise TypeError on f('a')?

Solution: Misconception: A type hint like `def f(x: int)` makes Python reject a str argument at runtime. Why it is wrong: Annotations are not enforced by CPython. They are metadata for checkers and readers. Correct: Use a type checker (or an explicit isinstance guard) if you need a runtime check.


Answer: BFS lists all leaves at distance 1 before going deeper; DFS may fully explore one spoke before another.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: On a star graph, why does BFS from the center differ from DFS?

Solution: Misconception: BFS and DFS always visit nodes in the same order on an undirected graph. Why it is wrong: BFS explores by distance from the start. DFS dives along one path first. Orders differ unless the graph is a path. Correct: Choose BFS for unweighted shortest paths. Choose DFS for connectivity, finishing times, or cycle checks.


Answer: The mean is 26.5, dominated by 100. The median is 2.5 and describes the typical small values.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: For values 1, 2, 3, 100, why might you prefer the median?

Solution: Misconception: The mean is always the best one-number summary of a numeric list. Why it is wrong: A single extreme value can drag the mean. The median is resistant to that skew. Correct: Report mean when the distribution is roughly symmetric; report median (and maybe IQR) when outliers matter.


Answer: Not net heat, once they are in thermal equilibrium. Heat flow requires a temperature difference.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: Can two objects at the same temperature exchange heat?

Solution: Misconception: Heat and temperature are two names for the same quantity. Why it is wrong: Temperature is an intensive state variable. Heat is energy transferred because of a temperature difference. Correct: A large lake and a cup of tea can share a temperature while storing very different amounts of thermal energy.


Answer: It receives 3 asynchronously and yields 4. The original work is not rerun.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: If a Promise is already fulfilled with 3, what does a later .then(x => x+1) receive?

Solution: Misconception: Calling .then on a Promise starts the async work a second time. Why it is wrong: A Promise represents one eventual result. Additional then-handlers observe that same settlement. Correct: The executor runs once. later .then calls receive the already-resolved or already-rejected value.


Answer: The predicate is on created_at. An email index does not order or filter that column.

Correct the misconception; do not invent a new error.

Name the false belief
Explain the mechanism
State the correction

Prompt: Why might CREATE INDEX on users.email not help WHERE users.created_at > '2024-01-01'?

Solution: Misconception: An index on column a also speeds WHERE b = 1 even if a is never mentioned. Why it is wrong: A B-tree on a cannot locate rows by b. The planner still needs a scan unless another index matches the predicate. Correct: Index usefulness depends on matching predicates, join keys, and selectivity—not on 'having some index'.


Answer: 8

Apply the definition
Compute
Record the number

Prompt: What is 17 - 9?


Answer: 42

Apply the definition
Compute
Record the number

Prompt: What is 6 × 7?


Answer: 5

Apply the definition
Compute
Record the number

Prompt: Solve 3x - 6 = 9. What is x?

Solution: 3x=15, x=5.


Answer: 40

Apply the definition
Compute
Record the number

Prompt: A rectangle is 5 by 8. What is the area?


Answer: 1/6

Apply the definition
Compute
Record the number

Prompt: A fair six-sided die. P(rolling a 5) as a reduced fraction a/b. Report a/b.

Solution: One favorable face of six.


Answer: 5

Apply the definition
Compute
Record the number

Prompt: Mean of 2, 4, 6, 8?


Answer: 5

Apply the definition
Compute
Record the number

Prompt: Two 10 ohm resistors in parallel. Equivalent resistance in ohms?

Solution: 1/R=1/10+1/10; R=5.


Answer: 4

Apply the definition
Compute
Record the number

Prompt: A wave travels 12 m in 3 s. Speed in m/s?


Answer: 24

Apply the definition
Compute
Record the number

Prompt: How many grams in 2 mol of a 12 g/mol element?

Solution: m=nM=24 g.


Answer: 60

Apply the definition
Compute
Record the number

Prompt: mgh with m=2 kg, g=10 m/s2, h=3 m. Potential energy in J?

Solution: E=60 J.


Answer: 15

Apply the definition
Compute
Record the number

Prompt: A loop runs n=5 times, each time doing 3 constant steps. How many steps?


Answer: 6

Apply the definition
Compute
Record the number

Prompt: How many 2-element subsets of {a,b,c,d}?


Answer: 11

Apply the definition
Compute
Record the number

Prompt: Dot product of (1,2) and (3,4)?


Answer: 1

Apply the definition
Compute
Record the number

Prompt: What is 29 mod 7?


Answer: 0.25

Apply the definition
Compute
Record the number

Prompt: Aa × Aa, P(aa) as a decimal 0.25 or fraction 1/4. Report 0.25.

Solution: One of four Punnett cells.


Answer: 16

Apply the definition
Compute
Record the number

Prompt: Arithmetic sequence 4, 7, 10. What is the 5th term?

Solution: a_n=4+3(n-1); n=5 gives 16.


Answer: -2

Apply the definition
Compute
Record the number

Prompt: Magnification m=-v/u with v=10, u=5 (same units). What is m?


Answer: 10

Apply the definition
Compute
Record the number

Prompt: Convert 10 °C of temperature change to kelvin difference.

Solution: ΔT in K equals ΔT in °C.


Answer: Multiplication binds more tightly than addition, matching ordinary 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: Why does `3 + 2 * 4` evaluate to 11 in Python rather than 20?

Solution: * and / are tighter than + and -. Parentheses override. 2*4=8, then 3+8=11.


Answer: 512; exponentiation associates to the right, so 2**(3**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: What is the value of `2 ** 3 ** 2` in Python, and which way does `**` associate?

Solution: 3**2 is 9, then 2**9 is 512. Left-associative would have been (2**3)**2 = 64.


Answer: `if x:` tests truthiness. `if x is True:` tests identity with the boolean True.

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 `if x:` and `if x is True:` when x might be 1 or []?

Solution: 1 is truthy but is not True. [] is falsy. Use `is True` only when you mean the boolean singleton.


Answer: Single `=` is assignment and is a SyntaxError there. Use `if n == 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 script uses `if n = 0:` to test a counter. Why does it fail, and what should it be?

Solution: Comparisons use ==. Assignment is a statement, not a boolean test, in that position.


Answer: The instance is passed implicitly on the call; `self` names that instance inside the 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: Why does `self` appear as the first parameter of an instance method?

Solution: obj.method(x) is type(obj).method(obj, x). The first parameter is the instance, by convention named self.


Answer: Both see the append unless the instance rebound the name to a new object.

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 happens if two instances share a class variable list and one appends to it?

Solution: Class attributes are shared. Mutable class attributes alias across instances. Use instance attributes created in __init__ for per-object state.


Answer: Raise when the caller passed something illegal and must notice. Return None only if absence is a normal outcome.

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 should a function raise ValueError versus returning None?

Solution: Exceptions make the failure path visible. Silent None hides bugs at the next dereference.


Answer: It hides bugs and can swallow KeyboardInterrupt subclasses of Exception in some paths. Catch the specific parse error, log, and re-raise unexpected types.

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 parser wraps a whole file in `except Exception: pass`. Name two harms and a tighter pattern.

Solution: Prefer `except json.JSONDecodeError`. Never use a bare except. Avoid swallowing Exception at process boundaries without logging.


Answer: Import sets __name__ to the module name, so the guard skips CLI side effects. Direct execution sets it to '__main__'.

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 `if __name__ == '__main__':` guard a script's CLI?

Solution: Libraries should be importable without launching the program. The guard separates library functions from the entry point.


Answer: A list is an iterable that mints a fresh iterator. A generator is the iterator and is exhausted.

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 you iterate a list twice but not consume a generator twice?

Solution: iter(list) starts over. A generator's next() advances hidden state until StopIteration.


Answer: An assertion fails the test automatically when the condition is false; a print requires a human to notice.

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 makes an assertion in a unit test different from a print of the result?

Solution: Tests must be machine-checkable. assertEqual documents the expected value and fails closed.


Answer: Later tests see leftover state (order dependence). Isolate fixtures: copy, use setUp/tearDown, or construct fresh objects per test.

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 mutates a shared module-level list in setUp and never restores it. What goes wrong, and how do you fix it?

Solution: Shared mutable fixtures create flakes. Each test should own its data.


Answer: The algorithm discards a half based on order. Without sorted order those discards are unjustified.

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 binary search incorrect on an unsorted array even if it sometimes finds the key?

Solution: Correctness of binary search is a loop invariant on a sorted range, not a lucky hit.


Answer: Theta(n^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: A nested loop runs i from 1..n and j from 1..i. What is Theta of the inner-body executions?

Solution: Sum_{i=1..n} i = n(n+1)/2 which is Theta(n^2).


Answer: Big-O is an upper bound. A quadratic function is also O(n^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: Why is O(n^2) not a contradiction of O(n^3) for the same function?

Solution: f(n)=n^2 is O(n^2) and O(n^3). Theta(n^2) is the tight characterization.


Answer: It recurses until the call stack overflows (or hits the recursion limit).

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 factorial function calls factorial(n) without a base case for n==0. What happens for factorial(3)?

Solution: Every recursive definition needs a base case that returns without another call. 0! is 1.


Answer: It recomputes the same subproblems in two branches, forming an exponential call tree.

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 naive recursive Fibonacci be exponential time?

Solution: T(n)=T(n-1)+T(n-2)+O(1) is Theta(phi^n). Memoization or iteration makes it linear.


Answer: INNER JOIN requires a match in both tables. LEFT JOIN keeps all left rows and nulls the right side when unmatched.

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 INNER JOIN drop customers with no orders while LEFT JOIN can keep them?

Solution: Choose INNER when you only want matches. Choose LEFT when absence is information.


Answer: name is not functionally determined by dept, so SQL rejects an ungrouped non-aggregated column.

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 `SELECT dept, COUNT(*) FROM emp GROUP BY dept`, why is `SELECT name` illegal without aggregation or grouping name?

Solution: GROUP BY dept yields one row per department. A per-employee column is not defined on that row.


Answer: 401 means unauthenticated (missing/bad credentials). 403 means authenticated but not 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: What is the difference between HTTP 401 and 403?

Solution: 401 invites supplying credentials. 403 says this principal may not access the resource.


Answer: Revert adds a new commit that undoes a change. Hard reset moves history others still have.

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 revert` safer than `git reset --hard` on a branch others already pulled?

Solution: Shared branches should grow with new commits, not rewrite published history.


Answer: A closure retains the lexical environment where it was created, not a snapshot of the caller's stack frame after return.

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 JavaScript, why does a function returned from another function still see the outer variable?

Solution: The inner function closes over bindings. Those bindings live as long as the function value is reachable.


Answer: `var` is function-scoped so all callbacks share one i, which is 3 after the loop. Use let, or bind i in a factory.

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 (var i=0;i<3;i++){ setTimeout(()=>console.log(i),0) }` prints 3 three times. Why, and how do you log 0,1,2?

Solution: let creates a fresh binding per iteration. var does not.


Answer: Ownership transferred. Using the old name would be a use-after-move, which Rust rejects.

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 moving a String into a function make the original binding unusable afterward?

Solution: Each value has one owner. Move ends the previous owner's access unless the type is Copy.


Answer: Close means no more sends; further sends are programmer errors. Receives drain then produce zero values so range can stop.

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 sending on a closed Go channel a panic while receiving after close yields zeros?

Solution: Only the sender should close. Use the two-value receive to detect closure.


Answer: A function assigns one output per input. A vertical line gives many y for one x.

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 vertical line not the graph of a function y=f(x)?

Solution: The vertical-line test is the unique-output rule in the plane.


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 right triangle has legs 3 and 4. What is the hypotenuse?

Solution: Pythagoras: sqrt(9+16)=sqrt(25)=5.


Answer: 100*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: A circle has radius 10. What is its area in terms of pi?

Solution: A=pi r^2 = pi*100.


Answer: 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 sin(pi/2) in radians?

Solution: pi/2 radians is 90 degrees; sine of a right angle is 1.


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 3-element subsets does a 5-element set have?


Answer: 1/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: A fair coin is flipped twice. What is P(exactly one head)?

Solution: Outcomes HH,HT,TH,TT equally likely. Exactly one head: HT, TH. 2/4=1/2.


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: What is the determinant of the 2x2 matrix [[2, 0], [0, 3]]?

Solution: ad-bc = 2*3-0*0=6.


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: What is 17 mod 5?


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 2 kg mass moves at 3 m/s. What is its kinetic energy in joules?

Solution: KE=1/2 m v^2 = 0.5*2*9=9 J.


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 12 V battery drives 3 A through a resistor. What is the resistance in ohms?

Solution: V=IR so R=V/I=12/3=4 ohm.


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: Water is H2O. How many moles of hydrogen atoms are in 2 moles of water?

Solution: Each water molecule has 2 H atoms, so 2 mol water contains 4 mol H atoms.


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: A wave has speed 10 m/s and frequency 5 Hz. What is the wavelength in meters?

Solution: v=f lambda so lambda=v/f=10/5=2 m.


Answer: Without untreated plants you cannot separate fertilizer from other growth factors.

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 control group needed when testing whether a fertilizer increases plant height?

Solution: A control holds other variables and shows the baseline. The difference is the evidence, not the treated height alone.


Answer: Lists are mutable and unhashable. Use a tuple of immutables, or freeze the data.

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 a poor choice as a dict key, and what should you use instead?

Solution: Hash tables require a stable hash. Mutating a key would lose the bucket.


Answer: Indexing is extra machinery and off-by-one prone. Iterating values states the intent.

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 `for i in range(len(xs)):` often worse than `for x in xs:` when you only need values?

Solution: Use enumerate if you need index and value. Direct iteration is the default.


Answer: Namespace packages allow import without __init__.py. It fails if another pack on sys.path is a regular package that hides the namespace, or if the directory is not on sys.path.

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 package directory has foo.py but no __init__.py on Python 3.3+. Why can `import pack.foo` still work, and when would it fail?

Solution: PEP 420 namespace packages. Explicit __init__.py still makes a regular package. Path order decides which pack wins.


Answer: No. The iterator was exhausted by the first list() call. A second pass needs a new iterator.

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 `it = iter(xs); list(it); list(it)` and the second list is empty. Is that a bug in list()?

Solution: list(it) consumes it. Call iter(xs) again, or keep the original sequence.


Answer: Full sort is Theta(n log n). A bounded heap is O(n log k), which is smaller when k << 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 need the k smallest elements of n numbers, k much smaller than n. Why is a size-k heap often better than fully sorting?

Solution: Each of n insertions/evictions costs O(log k) on a heap of size k. Sorting pays for order you will discard.


Answer: The first POST may have succeeded, so a retry can create a duplicate. Idempotent methods or client-generated idempotency keys make retries safe.

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 retries a POST that created a resource after a timeout with no response. What can go wrong, and what property would make the retry safe?

Solution: Timeouts are not failures. POST is not idempotent by default. PUT to a known URL or an Idempotency-Key header addresses duplicate creates.


Answer: Git only sees overlapping text hunks. It cannot tell which behaviour is intended. A human must combine or choose the correct function body and test 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: Two people edited the same function on different branches. A merge stops with conflict markers. What does Git not know, and what must a human decide?

Solution: Conflict markers are not a compiler. Resolve, remove markers, and run tests before committing the merge.


Answer: Use-after-move. Clone if you need two owned Strings, or print before moving, or borrow with &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: This snippet fails to compile: `let s = String::from("hi"); let t = s; println!("{}", s);`. What is the error class, and how do you print both?

Solution: s was moved into t. Clone costs an allocation. Borrowing lets both names observe the same value without a second owner.


Answer: The send blocks forever if nobody receives; when main returns the process exits and the work is lost. Wait with a receive, WaitGroup, or a done channel.

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 goroutine sends on an unbuffered channel and the main function returns without receiving. What happens to that send, and how do you wait correctly?

Solution: Unbuffered send synchronizes with a receive. Exiting main does not drain other goroutines.


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: f(x)=2x+1 and g(x)=x^2. What is (f ∘ g)(3)?

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


Answer: Opposite is a side of the triangle, so it cannot exceed the hypotenuse. Their ratio is at most 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: Why must sine of an angle in a right triangle be at most 1?

Solution: sin = opposite/hypotenuse. Sides are positive and opposite ≤ hypotenuse.


Answer: Each element is independently in or out, giving 2 choices per element, so 2^n subsets.

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 the number of subsets of an n-element set 2^n, including the empty set?

Solution: The empty set is the all-out choice. The full set is the all-in choice.


Answer: The intersection would be counted twice. Use P(A)+P(B)-P(A and B).

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 you not add P(A) and P(B) to get P(A or B) when A and B can both happen?

Solution: Inclusion-exclusion. Independent events still have a nonempty intersection in general.


Answer: Determinant 0 means the columns are linearly dependent, so the map collapses a line to a point and is not injective.

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 2x2 matrix with determinant 0 fail to have an inverse?

Solution: Invertible linear maps are bijective. A collapsed direction cannot be undone.


Answer: Each remainder is a strictly smaller nonnegative integer, so the sequence of remainders cannot descend forever.

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 Euclid's algorithm terminate when computing gcd(a,b) for positive integers?

Solution: Well-ordering of nonnegative integers. gcd(a,b)=gcd(b, a mod b) preserves the gcd.


Answer: KE is (1/2)mv^2, a square. Potential energy is defined up to an additive constant, so the zero point is a convention.

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 kinetic energy never be negative in classical mechanics while gravitational potential can be set negative?

Solution: Speed squared is nonnegative. You may choose PE=0 at infinity, making bound orbits negative.


Answer: The balanced equation requires a fixed mole ratio. When one reactant is used up, leftover excess cannot form more product.

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 limiting reactant stop a reaction even if the other reactant is still present?

Solution: Stoichiometry is a ratio, not 'mix until gone'. Compute moles and compare to coefficients.


Answer: Wavelength halves because v=fλ with v constant.

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 you double frequency while holding wave speed fixed, what happens to wavelength, and why?

Solution: λ=v/f. Doubling f halves λ.


Answer: Membership in a list is linear, so the loop can be quadratic. A set gives average-case O(1) membership.

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 `seen = [];` then `if x not in seen: seen.append(x)` inside a hot loop of 10^6 items. What is the complexity problem, and what structure fixes membership?

Solution: Use a set for 'have I seen this hashable x'. Lists preserve order if you also need insertion order; dict/set already do in modern CPython.


Answer: A possible infinite loop: i may never change. Increment in a path that always runs, or add a termination condition that does not depend on the skipped branch.

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 while loop increments i only inside an `if` that sometimes fails, and i starts at 0. What class of bug is this, and what is the usual repair?

Solution: Loop variables must progress. Put i += 1 outside the failing if, or restructure.


Answer: y is 4. Integers are immutable; x was rebound, y was not.

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 = 4; y = x; x = 5`, what is y, and did y change because x changed?

Solution: Rebinding x does not follow other names. y still refers to 4.


Answer: You cannot add numerators and denominators separately. Common denominator 6 gives 3/6+2/6=5/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: Why is 1/2 + 1/3 not 2/5?

Solution: Fractions are ratios. 2/5 would be a different ratio, not the sum of halves and thirds.


Answer: 3*x**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: What is the derivative of x^3 with respect to x?

Solution: Power rule: n x^{n-1}. Here n=3.


Answer: Newton's first law: zero net force means constant velocity, which may be 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: If net force is zero, why can an object still be moving?

Solution: Force changes velocity. Zero net force means no acceleration, not necessarily rest.


Answer: The list comprehension materializes every result immediately. The generator yields values lazily and can be iterated only once.

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 `[x*x for x in xs if x>0]` and a generator expression `(x*x for x in xs if x>0)`?

Solution: Use the list when you need len, reuse, or random access. Use the generator for streaming large sequences.


Answer: [0, 2, 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 for n in range(6) if n % 2 == 0]` produce?

Solution: range(6) is 0..5. The filter keeps evens.


Answer: It replaces g with the result of f(g). f must return a callable (usually a wrapper).

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 `@f` above `def g():` actually do at definition time?

Solution: `def g` binds the original function, then `g = f(g)` runs. That is why argumentless decorators are callables that take a function.


Answer: The wrapper overwrote __name__. Apply @functools.wraps(func) on the inner function.

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 timing decorator's wrapper is named `inner` and tests assert `fn.__name__ == 'compute'`. Why do they fail, and what one-line fix is conventional?

Solution: wraps copies __name__, __doc__, and __module__ from the wrapped function.


Answer: __exit__ runs during stack unwind, so close happens on both success and exception paths.

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 `with open(path) as f:` close the file even if the body raises?

Solution: The with-statement is try/finally around __enter__/__exit__. You still see the exception unless __exit__ swallows it.


Answer: Use with lock: so release runs if the critical section raises. Hand-paired acquire/release is easy to skip on error paths.

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 should you write a context manager for a lock versus calling acquire/release by hand?

Solution: Locks, files, and sessions are the usual with-targets because cleanup must be reliable.


Answer: No. The annotation is not enforced at runtime. A type checker can still flag append('a').

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 `x: list[int] = []` prevent appending a string at runtime in CPython?

Solution: Hints document intent. Runtime checks need isinstance or a validator.


Answer: It documents that None is a legal value. A plain str hint tells checkers that None is a mistake.

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 `Optional[str]` written as `str | None` in modern Python, and what does it allow that `str` does not?

Solution: Callers must handle None. The union is the type, not a runtime conversion.


Answer: The default encoding is locale-dependent, so the same bytes can decode differently on another machine.

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 should you pass encoding='utf-8' when opening text files rather than relying on the default?

Solution: Pin UTF-8 for portable text. Binary mode is for bytes that are not text.


Answer: Text mode used a locale encoding on write. Readers assuming UTF-8 mis-decode. Write with encoding='utf-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: A script writes JSON with `open(path,'w')` on Windows and a later reader on Linux sees garbage around non-ASCII. What went wrong?

Solution: JSON should be UTF-8. Never depend on the ANSI code page for interchange.


Answer: BFS expands by hop count, so the first time you reach a node is via a minimum number of edges. DFS can dive down a long path 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 does BFS find a shortest path in an unweighted graph while DFS generally does not?

Solution: Unweighted shortest path = fewest edges. Weights need Dijkstra or Bellman-Ford instead.


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: An undirected graph has 4 vertices and is a square (cycle of 4). How many edges does it have?

Solution: A C4 has four vertices and four edges.


Answer: Equal keys keep their original relative order. Mergesort is typically stable; heapsort is not.

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 it mean for a sort to be stable, and name one algorithm that is typically stable?

Solution: Stability matters when you sort by one key and then another. Unstable sorts can scramble the first key's order.


Answer: There are n! possible orders. Each comparison has two outcomes, so you need log2(n!) comparisons, which is Theta(n log n) by Stirling.

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 comparison sorting Omega(n log n) in the worst case in the comparison model?

Solution: Decision trees of height h distinguish at most 2^h leaves. n! > 2^{o(n log n)}.


Answer: Optimal substructure and overlapping subproblems. You store answers to repeated subproblems instead of recomputing them.

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 candidate for dynamic programming?

Solution: If subproblems do not overlap, divide-and-conquer without a table is enough. If they do, memoization or a bottom-up table pays off.


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: Naive recursive Fibonacci without memoization computes F(5). How many times is F(3) evaluated in the standard tree F(n)=F(n-1)+F(n-2) with F(0),F(1) bases?

Solution: F(5) calls F(4) and F(3). F(4) calls F(3) and F(2). F(3) appears twice.


Answer: The outcome depends on unsynchronized interleaving of accesses to shared state, so two runs with the same inputs can disagree.

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 a race condition, in one operational sentence?

Solution: Fix by keeping data thread-confined, using locks/atomics, or avoiding shared mutation.


Answer: Both read 0, both write 1. The increments are not atomic.

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 threads do `x = x + 1` on a shared integer without a lock. Why can the final x be 1 after both have 'incremented' once from 0?

Solution: Read-modify-write is three steps. A lock, or an atomic add, makes the pair one critical section.


Answer: Each process has its own virtual address space. The OS maps those addresses to physical memory separately.

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 two processes not see each other's local variables even though they run on the same CPU?

Solution: Isolation is a memory-management invariant. Shared memory exists only if explicitly requested.


Answer: User code is not allowed to access device memory or other processes' pages directly. The syscall is the controlled crossing.

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 user program calls read() and the kernel copies bytes into the process buffer. Why must that copy (or an equivalent mapping) be mediated by the kernel?

Solution: Protection rings / user vs supervisor mode. Drivers and page tables live on the kernel side.


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.