{ "examId": "python-intermediate-v1", "subject": "python", "title": "Python Intermediate - Comprehensive Assessment", "difficulty": "intermediate", "durationMinutes": 90, "sections": [ { "id": "sec-mcq-1", "title": "Multiple Choice - Python Fundamentals", "questions": [ { "id": "q1", "type": "single_choice", "prompt": "What is the output of: print(type(lambda x: x))?", "choices": [ { "key": "A", "text": "" }, { "key": "B", "text": "" }, { "key": "C", "text": "" }, { "key": "D", "text": "" } ], "answer": "A", "points": 2 }, { "id": "q2", "type": "single_choice", "prompt": "Which of the following is NOT a valid way to create a dictionary?", "choices": [ { "key": "A", "text": "d = {}" }, { "key": "B", "text": "d = dict()" }, { "key": "C", "text": "d = dict(a=1, b=2)" }, { "key": "D", "text": "d = [('a', 1), ('b', 2)]" } ], "answer": "D", "points": 2 }, { "id": "q3", "type": "single_choice", "prompt": "What does the 'yield' keyword do in Python?", "choices": [ { "key": "A", "text": "Returns a value and exits the function" }, { "key": "B", "text": "Creates a generator function" }, { "key": "C", "text": "Pauses the execution" }, { "key": "D", "text": "Raises an exception" } ], "answer": "B", "points": 2 }, { "id": "q4", "type": "single_choice", "prompt": "Which method is used to add an element to the end of a list?", "choices": [ { "key": "A", "text": "insert()" }, { "key": "B", "text": "append()" }, { "key": "C", "text": "extend()" }, { "key": "D", "text": "add()" } ], "answer": "B", "points": 2 }, { "id": "q5", "type": "single_choice", "prompt": "What is the result of: [1, 2, 3] + [4, 5]?", "choices": [ { "key": "A", "text": "[1, 2, 3, 4, 5]" }, { "key": "B", "text": "[[1, 2, 3], [4, 5]]" }, { "key": "C", "text": "[5, 7]" }, { "key": "D", "text": "Error" } ], "answer": "A", "points": 2 }, { "id": "q6", "type": "single_choice", "prompt": "Which of these is the correct way to open a file for reading?", "choices": [ { "key": "A", "text": "open('file.txt', 'r')" }, { "key": "B", "text": "file('file.txt', 'read')" }, { "key": "C", "text": "read('file.txt')" }, { "key": "D", "text": "open('file.txt', 'read')" } ], "answer": "A", "points": 2 }, { "id": "q7", "type": "single_choice", "prompt": "What does the 'with' statement do in Python?", "choices": [ { "key": "A", "text": "Creates a loop" }, { "key": "B", "text": "Imports a module" }, { "key": "C", "text": "Provides context management" }, { "key": "D", "text": "Defines a function" } ], "answer": "C", "points": 2 }, { "id": "q8", "type": "single_choice", "prompt": "Which built-in function returns the number of items in an object?", "choices": [ { "key": "A", "text": "count()" }, { "key": "B", "text": "size()" }, { "key": "C", "text": "len()" }, { "key": "D", "text": "length()" } ], "answer": "C", "points": 2 }, { "id": "q9", "type": "single_choice", "prompt": "What is the purpose of __init__ in a Python class?", "choices": [ { "key": "A", "text": "To initialize class variables" }, { "key": "B", "text": "To create a constructor" }, { "key": "C", "text": "To define instance initialization" }, { "key": "D", "text": "All of the above" } ], "answer": "D", "points": 2 }, { "id": "q10", "type": "single_choice", "prompt": "Which of these is NOT a Python data type?", "choices": [ { "key": "A", "text": "tuple" }, { "key": "B", "text": "array" }, { "key": "C", "text": "set" }, { "key": "D", "text": "frozenset" } ], "answer": "B", "points": 2 }, { "id": "q11", "type": "single_choice", "prompt": "What does the map() function return in Python 3?", "choices": [ { "key": "A", "text": "A list" }, { "key": "B", "text": "A map object (iterator)" }, { "key": "C", "text": "A tuple" }, { "key": "D", "text": "A dictionary" } ], "answer": "B", "points": 2 }, { "id": "q12", "type": "single_choice", "prompt": "Which keyword is used to create an anonymous function?", "choices": [ { "key": "A", "text": "def" }, { "key": "B", "text": "lambda" }, { "key": "C", "text": "function" }, { "key": "D", "text": "anonymous" } ], "answer": "B", "points": 2 }, { "id": "q13", "type": "single_choice", "prompt": "What is the correct way to handle exceptions in Python?", "choices": [ { "key": "A", "text": "try/catch" }, { "key": "B", "text": "try/except" }, { "key": "C", "text": "catch/finally" }, { "key": "D", "text": "error/handle" } ], "answer": "B", "points": 2 }, { "id": "q14", "type": "single_choice", "prompt": "Which module is used for regular expressions in Python?", "choices": [ { "key": "A", "text": "regex" }, { "key": "B", "text": "re" }, { "key": "C", "text": "regexp" }, { "key": "D", "text": "pattern" } ], "answer": "B", "points": 2 }, { "id": "q15", "type": "single_choice", "prompt": "What is the output of: bool([])?", "choices": [ { "key": "A", "text": "True" }, { "key": "B", "text": "False" }, { "key": "C", "text": "None" }, { "key": "D", "text": "Error" } ], "answer": "B", "points": 2 }, { "id": "q16", "type": "single_choice", "prompt": "Which method is used to remove whitespace from both ends of a string?", "choices": [ { "key": "A", "text": "trim()" }, { "key": "B", "text": "strip()" }, { "key": "C", "text": "remove()" }, { "key": "D", "text": "clean()" } ], "answer": "B", "points": 2 }, { "id": "q17", "type": "single_choice", "prompt": "What does *args allow in a function definition?", "choices": [ { "key": "A", "text": "Variable number of positional arguments" }, { "key": "B", "text": "Variable number of keyword arguments" }, { "key": "C", "text": "Required arguments" }, { "key": "D", "text": "Optional arguments" } ], "answer": "A", "points": 2 }, { "id": "q18", "type": "single_choice", "prompt": "Which operator is used for floor division in Python?", "choices": [ { "key": "A", "text": "/" }, { "key": "B", "text": "//" }, { "key": "C", "text": "%" }, { "key": "D", "text": "div" } ], "answer": "B", "points": 2 }, { "id": "q19", "type": "single_choice", "prompt": "What is the correct syntax for a list comprehension?", "choices": [ { "key": "A", "text": "[x for x in range(10)]" }, { "key": "B", "text": "(x for x in range(10))" }, { "key": "C", "text": "{x for x in range(10)}" }, { "key": "D", "text": "for x in range(10): x" } ], "answer": "A", "points": 2 }, { "id": "q20", "type": "single_choice", "prompt": "Which method converts a string to lowercase?", "choices": [ { "key": "A", "text": "toLower()" }, { "key": "B", "text": "lowercase()" }, { "key": "C", "text": "lower()" }, { "key": "D", "text": "downcase()" } ], "answer": "C", "points": 2 }, { "id": "q21", "type": "single_choice", "prompt": "What is the purpose of the 'pass' statement?", "choices": [ { "key": "A", "text": "To skip the current iteration" }, { "key": "B", "text": "To do nothing (placeholder)" }, { "key": "C", "text": "To return None" }, { "key": "D", "text": "To exit the loop" } ], "answer": "B", "points": 2 }, { "id": "q22", "type": "single_choice", "prompt": "Which of these is a mutable data type?", "choices": [ { "key": "A", "text": "tuple" }, { "key": "B", "text": "string" }, { "key": "C", "text": "list" }, { "key": "D", "text": "int" } ], "answer": "C", "points": 2 }, { "id": "q23", "type": "single_choice", "prompt": "What does the enumerate() function return?", "choices": [ { "key": "A", "text": "A list of tuples with index and value" }, { "key": "B", "text": "An enumerate object (iterator)" }, { "key": "C", "text": "A dictionary" }, { "key": "D", "text": "A range object" } ], "answer": "B", "points": 2 }, { "id": "q24", "type": "single_choice", "prompt": "Which decorator is used to define a class method?", "choices": [ { "key": "A", "text": "@staticmethod" }, { "key": "B", "text": "@classmethod" }, { "key": "C", "text": "@method" }, { "key": "D", "text": "@class" } ], "answer": "B", "points": 2 }, { "id": "q25", "type": "single_choice", "prompt": "What is the result of: 'python'[1:4]?", "choices": [ { "key": "A", "text": "pyt" }, { "key": "B", "text": "yth" }, { "key": "C", "text": "ytho" }, { "key": "D", "text": "pyth" } ], "answer": "B", "points": 2 } ] }, { "id": "sec-mcq-2", "title": "Multiple Choice - Advanced Concepts", "questions": [ { "id": "q26", "type": "single_choice", "prompt": "What is a closure in Python?", "choices": [ { "key": "A", "text": "A function that returns another function" }, { "key": "B", "text": "A function that has access to variables from its enclosing scope" }, { "key": "C", "text": "A private function" }, { "key": "D", "text": "A function without parameters" } ], "answer": "B", "points": 2 }, { "id": "q27", "type": "single_choice", "prompt": "What does the zip() function do?", "choices": [ { "key": "A", "text": "Compresses files" }, { "key": "B", "text": "Combines multiple iterables into tuples" }, { "key": "C", "text": "Filters a list" }, { "key": "D", "text": "Sorts a list" } ], "answer": "B", "points": 2 }, { "id": "q28", "type": "single_choice", "prompt": "Which of these creates a shallow copy of a list?", "choices": [ { "key": "A", "text": "list.copy()" }, { "key": "B", "text": "list[:]" }, { "key": "C", "text": "list(list)" }, { "key": "D", "text": "All of the above" } ], "answer": "D", "points": 2 }, { "id": "q29", "type": "single_choice", "prompt": "What is the purpose of __str__ method in a class?", "choices": [ { "key": "A", "text": "To convert the object to a string for display" }, { "key": "B", "text": "To compare two objects" }, { "key": "C", "text": "To initialize the object" }, { "key": "D", "text": "To delete the object" } ], "answer": "A", "points": 2 }, { "id": "q30", "type": "single_choice", "prompt": "What does the 'is' operator check?", "choices": [ { "key": "A", "text": "Value equality" }, { "key": "B", "text": "Type equality" }, { "key": "C", "text": "Identity (same object in memory)" }, { "key": "D", "text": "None of the above" } ], "answer": "C", "points": 2 }, { "id": "q31", "type": "single_choice", "prompt": "Which of these is the correct way to import all functions from a module?", "choices": [ { "key": "A", "text": "import module.*" }, { "key": "B", "text": "from module import *" }, { "key": "C", "text": "import * from module" }, { "key": "D", "text": "include module" } ], "answer": "B", "points": 2 }, { "id": "q32", "type": "single_choice", "prompt": "What is the output of: print(10 // 3)?", "choices": [ { "key": "A", "text": "3.33" }, { "key": "B", "text": "3" }, { "key": "C", "text": "4" }, { "key": "D", "text": "3.0" } ], "answer": "B", "points": 2 }, { "id": "q33", "type": "single_choice", "prompt": "Which method is used to remove and return an arbitrary element from a set?", "choices": [ { "key": "A", "text": "remove()" }, { "key": "B", "text": "discard()" }, { "key": "C", "text": "pop()" }, { "key": "D", "text": "delete()" } ], "answer": "C", "points": 2 }, { "id": "q34", "type": "single_choice", "prompt": "What is the difference between '==' and 'is'?", "choices": [ { "key": "A", "text": "'==' checks value, 'is' checks identity" }, { "key": "B", "text": "They are the same" }, { "key": "C", "text": "'==' checks type, 'is' checks value" }, { "key": "D", "text": "'is' is faster" } ], "answer": "A", "points": 2 }, { "id": "q35", "type": "single_choice", "prompt": "Which function is used to get the absolute value of a number?", "choices": [ { "key": "A", "text": "absolute()" }, { "key": "B", "text": "abs()" }, { "key": "C", "text": "fabs()" }, { "key": "D", "text": "absolute_value()" } ], "answer": "B", "points": 2 } ] }, { "id": "sec-tf-1", "title": "True/False - Python Basics", "questions": [ { "id": "q36", "type": "true_false", "prompt": "Python is a statically typed language.", "answer": false, "points": 2 }, { "id": "q37", "type": "true_false", "prompt": "Lists in Python can contain elements of different types.", "answer": true, "points": 2 }, { "id": "q38", "type": "true_false", "prompt": "The 'global' keyword is used to modify a variable outside the current scope.", "answer": true, "points": 2 }, { "id": "q39", "type": "true_false", "prompt": "Python uses curly braces {} to define code blocks.", "answer": false, "points": 2 }, { "id": "q40", "type": "true_false", "prompt": "Dictionaries in Python 3.7+ maintain insertion order.", "answer": true, "points": 2 }, { "id": "q41", "type": "true_false", "prompt": "The 'elif' keyword is short for 'else if'.", "answer": true, "points": 2 }, { "id": "q42", "type": "true_false", "prompt": "Python strings are mutable.", "answer": false, "points": 2 }, { "id": "q43", "type": "true_false", "prompt": "The range() function returns a list in Python 3.", "answer": false, "points": 2 }, { "id": "q44", "type": "true_false", "prompt": "Python supports multiple inheritance.", "answer": true, "points": 2 }, { "id": "q45", "type": "true_false", "prompt": "The 'break' statement terminates the entire program.", "answer": false, "points": 2 }, { "id": "q46", "type": "true_false", "prompt": "List comprehensions are generally faster than equivalent for loops.", "answer": true, "points": 2 }, { "id": "q47", "type": "true_false", "prompt": "Python allows you to chain comparison operators (e.g., 1 < x < 10).", "answer": true, "points": 2 }, { "id": "q48", "type": "true_false", "prompt": "The 'in' operator can be used with dictionaries to check for keys.", "answer": true, "points": 2 }, { "id": "q49", "type": "true_false", "prompt": "Python uses 0-based indexing for sequences.", "answer": true, "points": 2 }, { "id": "q50", "type": "true_false", "prompt": "The 'None' keyword is equivalent to null in other languages.", "answer": true, "points": 2 } ] } ], "metadata": { "createdAt": "2025-10-20T19:40:00Z", "version": "1.0.0", "author": "AI Tutor", "totalPoints": 100, "autoScored": true, "questionCount": 50 } }