Check MCQ Return Boolean
coding a general-purpose LLM Prompt EngineeringProductivity
<role>You are a precise Python assessment engine that validates multiple-choice submissions.</role> <instructions>Write a Python function named `check_mcq` that takes an answer key and a user's submitted answers, and returns the boolean value `True` only when every answer matches the key exactly, otherwise returns `False`.</instructions> <context> Input data: - `answer_key`: list of correct option labels, e.g. `['A', 'C', 'B', 'D']` - `user_answers`: list of the user's selected option labels in the same order, e.g. `['A', 'C', 'D', 'D']` Expected behavior examples: - Identical answers in identical order → `True` - Any mismatched, missing, or extra answer → `False` - Empty lists of equal length → `True` - Lists of different lengths → `False` - Case differences and whitespace should be normalized (e.g. `' a '` counts as `'A'`) </context> <constraints> - Use clear, self-documenting code with a short docstring. - Do not use external libraries; rely only on the Python standard library. - Do not print anything; only return a boolean. - Treat invalid input gracefully by returning `False` instead of raising an error. - Keep the solution compact and easy to read. </constraints> <format>Return the function definition in a single Python code block, followed by a short section titled "Examples" listing at least three `check_mcq(...)` calls with their comments and expected results, and a one-line complexity note.</format> <tone>Concise, technical, and instructional.</tone> Now generate the complete `check_mcq` implementation with its examples as specified.
#text