iGET

Python Programming - MCQ Practice Questions

Core Python MCQs — syntax, data types, OOP, libraries for placements & IT exams.

189 questions | 100% Free

Q.181Medium

What is the worst-case time complexity of Quick Sort?

Q.182Medium

What will be the output of the following code? ```python def binary_search(arr, target): low, high = 0, len(arr) - 1 while low <= high: mid = (low + high) // 2 if arr[mid] == target: return mid elif arr[mid] < target: low = mid + 1 else: high = mid - 1 return -1 print(binary_search([2, 5, 8, 12, 16, 23], 12)) ```

Q.183Medium

Which of the following sorting algorithms has the best average-case time complexity?

Q.184Medium

What will be the output of the following code that uses recursion to compute the -th Fibonacci number? ```python def fib(n): if n <= 1: return n return fib(n - 1) + fib(n - 2) print(fib(6)) ```

Q.185Medium

What is the space complexity of Merge Sort?

Q.186Medium

What will be the output of the following Python code implementing linear search? ```python def linear_search(arr, target): for i, val in enumerate(arr): if val == target: return i return -1 result = linear_search([10, 30, 20, 50, 40], 50) print(result) ```

Q.187Medium

Which of the following correctly describes the working principle of Insertion Sort?

Q.188Medium

What will be the output of the following code that implements a recursive binary search? ```python def rec_binary_search(arr, low, high, target): if low > high: return -1 mid = (low + high) // 2 if arr[mid] == target: return mid elif arr[mid] < target: return rec_binary_search(arr, mid + 1, high, target) else: return rec_binary_search(arr, low, mid - 1, target) arr = [1, 3, 5, 7, 9, 11] print(rec_binary_search(arr, 0, len(arr) - 1, 7)) ```