Data Science · Python What is the value of 'python'[1:4]? A 'ytho' B 'yth' Correct answer C 'pyt' D 'pyth' MCQSEXAM Show answer Read explanation
Data Science · Python In standard CPython, what is the main effect of the Global Interpreter Lock (GIL)? A Global variables cannot be read by any function B Each thread receives its own private memory heap C Only one thread executes Python bytecode at a time Correct answer D Python code always runs on all CPU cores at once MCQSEXAM Show answer Read explanation
Data Science · Python What happens when a Python function contains the yield keyword? A It returns a generator that yields lazily Correct answer B It returns all of its values at once in a list C It can only be called once in the whole program D It pauses the entire program until input arrives MCQSEXAM Show answer Read explanation
Data Science · Python In Python, a decorator is: A A tool that formats code according to PEP 8 B A comment that documents what a function does C A function that wraps another function Correct answer D A special variable that stores class constants MCQSEXAM Show answer Read explanation
Data Science · Python Inside a function, what types do *args and **kwargs collect? A A tuple and a dictionary Correct answer B A dictionary and a tuple C Two separate lists D A list and a set MCQSEXAM Show answer Read explanation
Data Science · Python def add(item, box=[]): box.append(item); return box. What does calling add(1) and then add(2) return the second time? A An error B [1, 2] Correct answer C [2] D [1] MCQSEXAM Show answer Read explanation
Data Science · Python What does [x * x for x in range(4)] produce? A [0, 1, 4, 9] Correct answer B [0, 2, 4, 6] C [0, 1, 2, 3] D [1, 4, 9, 16] MCQSEXAM Show answer Read explanation
Data Science · Python Which Python function returns the smallest item? A minimum() B min() Correct answer C smallest() D least() MCQSEXAM Show answer Read explanation
Data Science · Python Which Python function returns the largest item? A maximum() B max() Correct answer C largest() D biggest() MCQSEXAM Show answer Read explanation
Data Science · Python Which Python function returns the absolute value? A absolute() B abs() Correct answer C modulus() D value() MCQSEXAM Show answer Read explanation
Data Science · Python Which Python function removes whitespace from string ends? A trim() B strip() Correct answer C clean() D remove() MCQSEXAM Show answer Read explanation
Data Science · Python Which Python function converts a string to lowercase? A lower() Correct answer B lowercase() C toLower() D casefold() MCQSEXAM Show answer Read explanation
Data Science · Python Which Python module is used for regular expressions? A regex B re Correct answer C string D pattern MCQSEXAM Show answer Read explanation
Data Science · Python Which Python function returns the length of an object? A count() B length() C len() Correct answer D size() MCQSEXAM Show answer Read explanation
Data Science · Python Which Python operator performs floor division? A / B // Correct answer C % D ** MCQSEXAM Show answer Read explanation
Data Science · Python What is the output of print(2 ** 3 ** 2) in Python? A 64 B 512 Correct answer C 36 D 256 MCQSEXAM Show answer Read explanation
Data Science · Python Which Python keyword is used to define a function? A function B define C def Correct answer D func MCQSEXAM Show answer Read explanation
Data Science · Python Which Python data type is immutable? A List B Dictionary C Tuple Correct answer D Set MCQSEXAM Show answer Read explanation
Data Science · Python Which data type in Python is used to represent a sequence of Unicode characters? A int B str Correct answer C float D list MCQSEXAM Show answer Read explanation
Data Science · Python What does the is operator check for when comparing two variables in Python? A Value equality B Reference equality Correct answer C Data type equality D Memory location equality MCQSEXAM Show answer Read explanation
Data Science · Python What is the output of {'a': 1, 'b': 2}.values() in Python? A [1, 2] Correct answer B {'a': 1, 'b': 2} C (1, 2) D Error MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following methods is used to remove an element from a set without raising an error if the element is not present? A remove() B pop() C discard() Correct answer D delete() MCQSEXAM Show answer Read explanation
Data Science · Python What is the result of 2 << 3 in Python? A 6 B 8 Correct answer C 14 D 64 MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following methods is used to convert a string representation of a number to its corresponding integer value? A to_int() B int() Correct answer C parse_int() D convert_to_int() MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following statements about tuples in Python is true? A Tuples can be modified after creation. B Tuples use square brackets [ ] for declaration. C Tuples can only contain immutable elements. Correct answer D Tuples can only contain integers. MCQSEXAM Show answer Read explanation