Daily Coding Quiz: Monday, 9 November 2026
All 10 coding questions with answers and explanations. 0 players took part.
What is printed?
Python · easy
print("hack" * 2 + "!")- hack2!
- hackhack!
- hack!hack!
- TypeError
Answer: B. hackhack!
Explanation: Multiplying a string by an integer repeats it; + then concatenates "!".
Which layer turns a vector of scores into probabilities that add up to 1?
AI & GenAI · easy
- ReLU
- Softmax
- Dropout
- Batch normalisation
Answer: B. Softmax
Explanation: softmax(zᵢ) = e^zᵢ / Σ e^zⱼ: every output is positive and they sum to 1, so it is used for multi-class outputs and next-token prediction.
What is printed?
Python · easy
print([x * x for x in range(5) if x % 2 == 0])- [0, 4, 16]
- [1, 9]
- [0, 1, 4, 9, 16]
- [4, 16]
Answer: A. [0, 4, 16]
Explanation: range(5) is 0–4; the even ones are 0, 2, 4, and their squares are 0, 4, 16.
What is the shape of a 640 × 480 colour image loaded with OpenCV (cv2.imread)?
Computer Vision · easy
- (640, 480, 3)
- (480, 640, 3)
- (3, 480, 640)
- (480, 640)
Answer: B. (480, 640, 3)
Explanation: NumPy arrays are (rows, columns, channels) = (height, width, 3). Also note OpenCV stores the channels as BGR, not RGB.
What is printed?
Python · medium
print(sorted(["banana", "Apple", "cherry"]))- ['Apple', 'banana', 'cherry']
- ['apple', 'banana', 'cherry']
- ['banana', 'cherry', 'Apple']
- ['cherry', 'banana', 'Apple']
Answer: A. ['Apple', 'banana', 'cherry']
Explanation: Strings sort by code point, and capital letters come before lowercase ones, so "Apple" is first here. Use key=str.lower to sort case-insensitively.
What is printed?
Python · medium
x = 10 def f(): x = 20 def g(): nonlocal x x += 1 g() return x print(f(), x)- 21 10
- 21 21
- 11 10
- 20 10
Answer: A. 21 10
Explanation: nonlocal makes g change f’s x (20 → 21). The global x stays 10.
What is printed?
Python · medium
def add(item, box=[]): box.append(item) return box add(1) print(add(2))- [2]
- [1, 2]
- []
- An error
Answer: B. [1, 2]
Explanation: Default values are evaluated once, when the function is defined. Both calls share the same list. Use box=None and create the list inside.
Your training and validation losses are both high and close together. What is the most useful next step?
Machine Learning · hard
- Add dropout and more regularisation
- Collect more of the same data
- Increase model capacity or add better features: the model is underfitting
- Use early stopping sooner
Answer: C. Increase model capacity or add better features: the model is underfitting
Explanation: High bias: the model can’t even fit the training data. Regularisation and early stopping fight variance, and more data mostly helps when the model overfits.
What is printed?
Python · hard
class Counter: count = 0 def __init__(self): self.count += 1 a, b = Counter(), Counter() print(Counter.count, a.count, b.count)- 0 1 1
- 2 2 2
- 2 1 2
- 0 0 0
Answer: A. 0 1 1
Explanation: self.count += 1 reads the class attribute (0) but writes a new instance attribute. The class attribute is never changed. Write Counter.count += 1 to share it.
What is printed?
Python · hard
def gen(): x = yield 1 yield x * 10 g = gen() print(next(g), g.send(5))- 1 50
- 1 10
- 1 None
- TypeError
Answer: A. 1 50
Explanation: next(g) runs to the first yield and gives 1. send(5) resumes the generator, making the paused yield expression evaluate to 5, so the next yield gives 50.