Hack4Hack

Daily Coding Quiz: Sunday, 8 November 2026

All 10 coding questions with answers and explanations. 0 players took part.

  1. What does len({"a": 1, "b": 2, "a": 3}) return?

    Python · easy

    1. 1
    2. 2
    3. 3
    4. An error

    Answer: B. 2

    Explanation: Dictionary keys are unique. The second "a" overwrites the first, leaving {"a": 3, "b": 2}.

  2. How do you correctly check for missing values in SQL?

    SQL · easy

    1. WHERE salary = NULL
    2. WHERE salary IS NULL
    3. WHERE salary = ''
    4. WHERE salary == NULL

    Answer: B. WHERE salary IS NULL

    Explanation: NULL is not equal to anything, not even NULL: salary = NULL is never true. Use IS NULL / IS NOT NULL.

  3. In k-nearest neighbours (k-NN) classification, how is a new point labelled?

    Machine Learning · easy

    1. By the majority label among its k closest training points
    2. By fitting a line through k points
    3. By the label of the farthest point
    4. By averaging all training labels

    Answer: A. By the majority label among its k closest training points

    Explanation: k-NN stores the training data and votes among the k nearest neighbours (by distance) at prediction time.

  4. What does a higher “temperature” do when sampling from an LLM?

    AI & GenAI · easy

    1. Makes answers more deterministic
    2. Makes output more random and varied
    3. Makes the model faster
    4. Increases the context window

    Answer: B. Makes output more random and varied

    Explanation: Temperature divides the logits before softmax. Above 1 flattens the distribution (more surprising tokens); near 0 almost always picks the top token.

  5. Which task draws a box around every object and names its class?

    Computer Vision · easy

    1. Image classification
    2. Object detection
    3. Semantic segmentation
    4. Image captioning

    Answer: B. Object detection

    Explanation: Detection gives a box and label per object (e.g. YOLO). Classification labels the whole image; segmentation labels every pixel.

  6. What is printed?

    Python · medium

    d = {"a": 1}
    print(d.get("b", 0), d.setdefault("b", 5), d)
    1. 0 5 {'a': 1, 'b': 5}
    2. 0 0 {'a': 1}
    3. None 5 {'a': 1, 'b': 5}
    4. KeyError

    Answer: A. 0 5 {'a': 1, 'b': 5}

    Explanation: get returns the default without inserting. setdefault inserts the key with the default when it is missing and returns it.

  7. What is printed?

    Python · medium

    funcs = [lambda: i for i in range(3)]
    print([f() for f in funcs])
    1. [0, 1, 2]
    2. [2, 2, 2]
    3. [0, 0, 0]
    4. An error

    Answer: B. [2, 2, 2]

    Explanation: Closures capture the variable, not its value. By the time the lambdas run, i is 2. Bind it now with lambda i=i: i.

  8. What is printed?

    Python · hard

    class A:
        def hi(self): return "A"
    class B(A):
        def hi(self): return "B" + super().hi()
    class C(A):
        def hi(self): return "C" + super().hi()
    class D(B, C):
        pass
    print(D().hi())
    1. BA
    2. BCA
    3. CBA
    4. BACA

    Answer: B. BCA

    Explanation: D’s method resolution order is D → B → C → A. super() follows the MRO, not the parent class, so B calls C, which calls A.

  9. In MySQL InnoDB, what is a covering index?

    SQL · hard

    1. An index on every column
    2. An index that holds every column a query needs, so the table rows never have to be read
    3. The clustered primary-key index
    4. An index on a JSON column

    Answer: B. An index that holds every column a query needs, so the table rows never have to be read

    Explanation: If the query’s WHERE, SELECT and ORDER BY columns are all in the index, InnoDB answers from the index alone. EXPLAIN shows “Using index”.

  10. You tune hyperparameters with cross-validation on the full dataset and report the best CV score as your final result. What is the problem?

    Machine Learning · hard

    1. None
    2. The score is optimistically biased: you selected the best of many tries on the same folds. Use nested CV or a held-out test set
    3. Cross-validation can’t tune hyperparameters
    4. The model will underfit

    Answer: B. The score is optimistically biased: you selected the best of many tries on the same folds. Use nested CV or a held-out test set

    Explanation: Picking the maximum over many configurations overfits to the validation folds. Nested cross-validation, or a final test set untouched during tuning, gives an honest estimate.

Play the next Daily Quiz at 4 PM IST