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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

original curriculum task; not copied from the source

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: {'a': 2}

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: 0

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

Read the prompt
Apply the concept
State the answer

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

Solution: fromkeys uses a shared default value.


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: yes

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

Read the prompt
Apply the concept
State the answer

Prompt: Is i32 Copy? Yes or no.

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: no

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: Concurrent map writes are undefined / can panic.

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: yes

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: 3

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: real

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

Read the prompt
Apply the concept
State the answer

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

Solution: Floating values are REAL affinity/storage.


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: unknown

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

Read the prompt
Apply the concept
State the answer

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

Solution: AND with unknown and true is unknown.


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: no

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

Solution: Save errno immediately, then log.


Answer: 2

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: 50

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: 11314

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: 2

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

Read the prompt
Apply the concept
State the answer

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


Answer: 0.3

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

Read the prompt
Apply the concept
State the answer

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: 100

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

Read the prompt
Apply the concept
State the answer

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

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


Answer: 48000

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

Read the prompt
Apply the concept
State the answer

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

Solution: 2*24000=48000 inches.


Answer: 5

CPython / common SQL / git unless stated

Identify the common pitfall
Answer the yes/no or count

Prompt: You need inclusive integers from 3 through 7. In Python, what is list(range(3, 8)) length?

Solution: range(start, stop) excludes stop; 3,4,5,6,7 → 5 values.


Answer: no

CPython / common SQL / git unless stated

Identify the common pitfall
Answer the yes/no or count

Prompt: Two naive datetime values differ by 3600 seconds locally. Does that prove they are one UTC hour apart? Answer yes or no.

Solution: Naive datetimes have no zone; DST and offset make local deltas unreliable as UTC.


Answer: no

CPython / common SQL / git unless stated

inspired_by=stackoverflow topic=json vs eval

Identify the common pitfall
Answer the yes/no or count

Prompt: Should untrusted text be turned into a Python object with eval? yes or no.

Solution: eval executes code. Use json.loads for JSON payloads.


Answer: no

CPython / common SQL / git unless stated

Identify the common pitfall
Answer the yes/no or count

Prompt: Is binary float a safe ledger type for USD cents? yes or no.

Solution: Use integer cents or decimal. Decimal/float rounding is not cash-safe.


Answer: no

CPython / common SQL / git unless stated

Identify the common pitfall
Answer the yes/no or count

Prompt: A dict key is a list. After insertion you mutate the list. Is lookup by the new list guaranteed? yes or no.

Solution: Mutable keys are invalid; lists are unhashable. If a custom mutable key were used, mutation would break the table.


Answer: no

CPython / common SQL / git unless stated

Identify the common pitfall
Answer the yes/no or count

Prompt: Two Python threads each run a tight CPU loop of bytecode. Will they typically use two cores at full speed under CPython's GIL? yes or no.

Solution: CPython's GIL usually serializes bytecode execution on one core.


Answer: no

CPython / common SQL / git unless stated

Identify the common pitfall
Answer the yes/no or count

Prompt: In SQL, does `NULL = NULL` evaluate to TRUE? yes or no.

Solution: NULL comparisons yield UNKNOWN; use IS NULL.


Answer: no

CPython / common SQL / git unless stated

Identify the common pitfall
Answer the yes/no or count

Prompt: You checkout a raw commit SHA. Are new commits still on a named branch? yes or no.

Solution: Detached HEAD: commits are not on a branch until you create/move one.


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

Solution: Commercial rights and attribution are separate license axes.


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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


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

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

Read the prompt
Apply the concept
State the answer

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

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