full-course.json
json Container
READ_ONLY_ACCESS[ { "id": "python-w01-000", "front": "Week 1 Diagnostic: What is the output of `type(5 / 2)` in Python 3?", "back": "Answer: B — In Python 3, the `/` operator always performs true float division, producing `2.5` (<class 'float'>). For integer division, use `//`." }, { "id": "python-w01-001", "front": "Week 1 Diagnostic: What does `int('10') + 5` evaluate to?", "back": "Answer: 15 — The string `'10'` is explicitly cast to integer `10`, and `10 + 5 = 15`." }, { "id": "python-w02-000", "front": "Week 2 Diagnostic: In Python, which of the following evaluates to False in a boolean context?", "back": "Answer: C — 0, empty collections `[]`, `{}`, `()`, empty strings `''`, and `None` evaluate to False. Non-empty collections like `[0]` and non-empty strings like `'False'` are truthy." }, { "id": "python-w02-001", "front": "Week 2 Diagnostic: What is the value of `True or (5 / 0 == 1)`?", "back": "Answer: B — Python uses short-circuit evaluation: since the left operand of `or` is True, the right operand is never evaluated, avoiding ZeroDivisionError." }, { "id": "python-w03-000", "front": "Week 3 Diagnostic: What does the expression `10 if 3 > 5 else 20` evaluate to?", "back": "Answer: 20 — Since `3 > 5` is False, the ternary expression returns the `else` branch value: 20." }, { "id": "python-w03-001", "front": "Week 3 Diagnostic: In Python, is the chained comparison `1 < 3 < 2` valid syntax, and what does it return?", "back": "Answer: C — Python allows chained comparisons: `1 < 3 < 2` is equivalent to `(1 < 3) and (3 < 2)`, which evaluates to `True and False` -> `False`." }, { "id": "python-w04-000", "front": "Week 4 Diagnostic: What is the sequence of integers generated by `list(range(2, 10, 3))`?", "back": "Answer: A — range(start, stop, step) starts at 2, steps by 3, and stops before 10: 2, 5, 8." }, { "id": "python-w04-001", "front": "Week 4 Diagnostic: How many times will a `while` loop with condition `count < 5` execute if `count` starts at 0 and increments by 1 each iteration?", "back": "Answer: 5 — Iterations for count = 0, 1, 2, 3, 4 -> 5 times." }, { "id": "python-w05-000", "front": "Week 5 Diagnostic: What happens when a `break` statement inside a loop executes?", "back": "Answer: B — `break` terminates the enclosing loop immediately. In contrast, `continue` skips to the next iteration." }, { "id": "python-w05-001", "front": "Week 5 Diagnostic: When does the `else` block attached to a `for` loop execute?", "back": "Answer: C — A loop's `else` clause runs when the loop finishes iterating all elements without hitting a `break`." }, { "id": "python-w06-000", "front": "Week 6 Diagnostic: For list `L = [1, 2, 3, 4, 5]`, what does `L[1:4]` return?", "back": "Answer: A — Slicing `L[1:4]` includes index 1, 2, 3 (values 2, 3, 4) and excludes index 4." }, { "id": "python-w06-001", "front": "Week 6 Diagnostic: If `A = [1, 2]`, and `B = A`, and then `B.append(3)` is run, what is the length of `A`?", "back": "Answer: 3 — `B = A` creates an alias to the exact same list in memory. Modifying `B` mutates `A`, so `len(A) = 3`." }, { "id": "python-w07-000", "front": "Week 7 Diagnostic: Can a list be used as a key in a Python dictionary?", "back": "Answer: B — Dictionary keys must be hashable and immutable. Lists are mutable and unhashable, raising `TypeError: unhashable type: 'list'`." }, { "id": "python-w07-001", "front": "Week 7 Diagnostic: What is the result of `len({1, 2, 2, 3, 3, 3})`?", "back": "Answer: 3 — Sets store only unique elements: `{1, 2, 3}` has length 3." }, { "id": "python-w08-000", "front": "Week 8 Diagnostic: What does the list comprehension `[x * 2 for x in range(5) if x % 2 == 0]` evaluate to?", "back": "Answer: A — Even numbers in range(5): 0, 2, 4. Multiplied by 2: 0, 4, 8." }, { "id": "python-w08-001", "front": "Week 8 Diagnostic: What does `sorted(['banana', 'pie', 'apple'], key=len)` sort the list by?", "back": "Answer: B — Passing `key=len` orders items by the result of `len(item)`: ['pie', 'apple', 'banana']." }, { "id": "python-w09-000", "front": "Week 9 Diagnostic: Why is it recommended to use `with open('file.txt', 'r') as f:` instead of `f = open(...)`?", "back": "Answer: B — The `with` statement acts as a context manager that guarantees the file descriptor is closed when the block exits." }, { "id": "python-w09-001", "front": "Week 9 Diagnostic: Which file open mode should be used to add data to an existing file without overwriting it?", "back": "Answer: C — Mode `'a'` (append) writes new data at the end of the file without clearing existing contents." }, { "id": "python-w10-000", "front": "Week 10 Diagnostic: In Python's `csv` module, what does `csv.DictReader` return for each row?", "back": "Answer: B — `csv.DictReader` maps each row into a dictionary using the header row as keys." }, { "id": "python-w10-001", "front": "Week 10 Diagnostic: Which block in a `try`-`except`-`finally` statement is ALWAYS executed regardless of whether an exception occurred?", "back": "Answer: D — The `finally` block always executes, commonly used for cleanup actions like releasing resources." }, { "id": "python-w11-000", "front": "Week 11 Diagnostic: What is the purpose of the `if __name__ == '__main__':` idiom in Python scripts?", "back": "Answer: B — `__name__` is `'__main__'` only when the script is run directly. When imported into another script, `__name__` is set to the module name." }, { "id": "python-w11-001", "front": "Week 11 Diagnostic: If a script is run as `python script.py data.csv 100`, what is the value of `sys.argv[1]`?", "back": "Answer: B — `sys.argv[0]` is the script name `'script.py'`; `sys.argv[1]` is the first CLI argument `'data.csv'`." }, { "id": "python-w12-000", "front": "Week 12 Diagnostic: If `A = np.array([1, 2, 3])`, what is the result of `A * 2`?", "back": "Answer: B — NumPy arrays perform element-wise vectorized arithmetic, so `A * 2` multiplies each element: `array([2, 4, 6])`." }, { "id": "python-w12-001", "front": "Week 12 Diagnostic: In Pandas, which method returns the first 5 rows of a DataFrame `df`?", "back": "Answer: B — `df.head()` displays the top 5 rows of a Pandas DataFrame by default." } ]