Hack4Hack

Daily Coding Quiz: Tuesday, 10 November 2026

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

  1. Why do we keep a separate test set?

    Machine Learning · easy

    1. To train the model faster
    2. To estimate how the model performs on data it has never seen
    3. To tune the learning rate
    4. To increase the training data

    Answer: B. To estimate how the model performs on data it has never seen

    Explanation: Performance on the training data is optimistic. A held-out test set, used once at the end, estimates real-world performance.

  2. A PRIMARY KEY column must be:

    SQL · easy

    1. Unique, and NULLs are allowed
    2. Unique and NOT NULL
    3. Indexed, but duplicates are allowed
    4. An integer

    Answer: B. Unique and NOT NULL

    Explanation: A primary key identifies each row, so it must be unique and cannot be NULL. It can be any type, or several columns together.

  3. What does the "is" operator compare?

    Python · medium

    1. Values
    2. Types
    3. Object identity (same object in memory)
    4. Hash values

    Answer: C. Object identity (same object in memory)

    Explanation: "is" checks whether two names point to the very same object; == compares values. Use "is" for None checks, == for values.

  4. What is the difference between UNION and UNION ALL?

    SQL · medium

    1. UNION removes duplicate rows; UNION ALL keeps them
    2. UNION ALL removes duplicates; UNION keeps them
    3. UNION only works on two tables
    4. There is no difference

    Answer: A. UNION removes duplicate rows; UNION ALL keeps them

    Explanation: UNION de-duplicates (which costs a sort or hash), UNION ALL simply appends. Prefer UNION ALL when duplicates are impossible or wanted.

  5. What does this return?

    SQL · medium

    -- Table employees(id, name, dept, salary):
    -- (1, Asha,  Eng,   90)
    -- (2, Ravi,  Eng,   70)
    -- (3, Meera, Sales, 60)
    -- (4, Kabir, Sales, 60)
    -- (5, Neha,  HR,    NULL)
    SELECT AVG(salary) FROM employees;
    1. 56
    2. 70
    3. 60
    4. NULL

    Answer: B. 70

    Explanation: Aggregates ignore NULLs: (90 + 70 + 60 + 60) / 4 = 70, not divided by 5. Use AVG(COALESCE(salary, 0)) to count NULLs as 0.

  6. What is printed?

    Python · medium

    print(0.1 + 0.2 == 0.3, round(0.1 + 0.2, 2) == 0.3)
    1. True True
    2. False True
    3. False False
    4. True False

    Answer: B. False True

    Explanation: 0.1 and 0.2 cannot be stored exactly in binary floating point, so the sum is 0.30000000000000004. Compare with round() or math.isclose().

  7. What does L1 (Lasso) regularisation tend to do that L2 (Ridge) does not?

    Machine Learning · medium

    1. Make the model non-linear
    2. Push some weights to exactly zero, selecting features
    3. Increase variance
    4. Remove the need for a test set

    Answer: B. Push some weights to exactly zero, selecting features

    Explanation: The L1 penalty has corners at zero, so optimal weights often land exactly on 0. L2 shrinks weights smoothly but rarely to exactly 0.

  8. What does this return for the Sales department?

    SQL · hard

    -- Table employees(id, name, dept, salary):
    -- (1, Asha,  Eng,   90)
    -- (2, Ravi,  Eng,   70)
    -- (3, Meera, Sales, 60)
    -- (4, Kabir, Sales, 60)
    -- (5, Neha,  HR,    NULL)
    SELECT name,
           RANK()       OVER (ORDER BY salary DESC) AS r,
           DENSE_RANK() OVER (ORDER BY salary DESC) AS dr
    FROM employees
    WHERE salary IS NOT NULL;
    1. Meera 3 3, Kabir 3 3
    2. Meera 3 3, Kabir 4 3
    3. Meera 3 3, Kabir 4 4
    4. Meera 2 2, Kabir 2 2

    Answer: A. Meera 3 3, Kabir 3 3

    Explanation: Salaries in order: 90, 70, 60, 60. The tie at 60 shares rank 3 in both. RANK would then skip to 5 and DENSE_RANK to 4 for the next row, but there isn’t one.

  9. In a diffusion image model, what does the network learn to predict during training?

    AI & GenAI · hard

    1. The class label
    2. The noise that was added to an image at a random noise level (or the clean image)
    3. The next pixel
    4. An image caption

    Answer: B. The noise that was added to an image at a random noise level (or the clean image)

    Explanation: Training adds Gaussian noise at a random timestep and teaches the network to predict that noise. Generation starts from pure noise and removes it step by step.

  10. Which statements about the CPython GIL are true? (Select all that apply)

    Python · hard

    1. Only one thread runs Python bytecode at a time
    2. Threads still help for I/O-bound work, since the GIL is released while waiting on I/O
    3. multiprocessing is a common way around it for CPU-bound work
    4. asyncio removes the GIL

    Answer: A. Only one thread runs Python bytecode at a time; B. Threads still help for I/O-bound work, since the GIL is released while waiting on I/O; C. multiprocessing is a common way around it for CPU-bound work

    Explanation: The GIL serialises bytecode execution, but blocking I/O releases it. Separate processes each have their own interpreter and GIL. asyncio is single-threaded concurrency and does not touch the GIL.

Play the next Daily Quiz at 4 PM IST