This quiz works best with JavaScript enabled. Home > Cbse > Class 12 > Science > Computer Science > Class 12 Computer Science Chapter 1 Data Structures Using Python – Quiz 2 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 2 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Consider an array of integers:[10, 25, 30, 45, 50, 65, 70, 85]. If you are searching for element 10, which searching technique would be most efficient A) Linear Search. B) Hashing. C) Binary Search. D) Jump Search. Show Answer Correct Answer: A) Linear Search. 2. In stack we can not insert an element in between the elements that are already inserted. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 3. What data structure in Python follows the Last In First Out (LIFO) principle? A) Array. B) Heap. C) Stack. D) Queue. Show Answer Correct Answer: C) Stack. 4. Discuss the concept of list comprehension in Python with an example. A) List comprehension is a method to create classes in Python. B) List comprehension in Python is a concise way to create lists. For example:squares = [x**2 for x in range(10)]. C) List comprehension is used to create tuples in Python. D) List comprehension is a way to create dictionaries in Python. Show Answer Correct Answer: B) List comprehension in Python is a concise way to create lists. For example:squares = [x**2 for x in range(10)]. 5. The operations performed by Stack are ..... A) Insert, delete. B) Push, pop. C) Add, delete. D) Enqueue and dequeue. Show Answer Correct Answer: B) Push, pop. 6. The ..... function is used to delete all the elements in a dictionary. A) Delete. B) Delete(). C) Clear( ). D) A & c. Show Answer Correct Answer: C) Clear( ). 7. How do you create a tuple in Python? A) Creating a list with curly braces, e.g., {1, 2, 3}. B) You create a tuple in Python by using parentheses, e.g., (1, 2, 3). C) Defining a tuple with the tuple() function, e.g., tuple(1, 2, 3). D) Using square brackets, e.g., [1, 2, 3]. Show Answer Correct Answer: B) You create a tuple in Python by using parentheses, e.g., (1, 2, 3). 8. It use pointer to link nodes. A) Pointer. B) Variable. C) Link List. D) Trees. Show Answer Correct Answer: C) Link List. 9. What is pointer in C language? A) It stores character variables. B) It stores string variables. C) It stores integer variables. D) It stores the address of the variable. Show Answer Correct Answer: D) It stores the address of the variable. 10. What type of queue allows insertion and deletion of elements at both ends? A) Simple Queue. B) Circular Queue. C) Double-Ended Queue (Deque). D) Priority Queue. Show Answer Correct Answer: C) Double-Ended Queue (Deque). 11. How do you create a two-dimensional list in Python? A) My list = [[1, 2, 3], [4, 5, 6], [7, 8]]. B) My list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. C) My list = [1, 2, 3; 4, 5, 6; 7, 8, 9]. D) My list = (1, 2, 3), (4, 5, 6), (7, 8, 9). Show Answer Correct Answer: B) My list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. 12. Collection of dissimilar type of data item is called A) Array. B) Structure. C) A & B Both. D) None of these. Show Answer Correct Answer: B) Structure. 13. Input/output function prototypes and macros are defined in which header file? A) Stdlib.h. B) Dos.h. C) Stdio.h. D) Conio.h. Show Answer Correct Answer: C) Stdio.h. 14. Which of the following is not a correct variable type? A) Int. B) Char. C) Real. D) Float. Show Answer Correct Answer: C) Real. 15. How would you access an item in a three-dimensional array? A) Using one index. B) Using two indexes. C) Using three indexes. D) Using four indexes. Show Answer Correct Answer: C) Using three indexes. 16. It is a method of solving problems that involves breaking a problem down into smaller and smaller sub problems until you get to a small enough problem that it can be solved trivially. A) Recursion. B) Iteration. C) Looping. D) None of the above. Show Answer Correct Answer: A) Recursion. 17. What is the only function all C programs must contain? A) Program(). B) Main(). C) System(). D) Start(). Show Answer Correct Answer: B) Main(). 18. How do you handle exceptions in Python using try and except blocks? A) Use try to wrap the code that may raise an exception, and use except to define how to handle the exception. B) Ignore exceptions and let the program crash. C) Wrap all code in a single except block regardless of the exception type. D) Use only try without except to handle exceptions. Show Answer Correct Answer: A) Use try to wrap the code that may raise an exception, and use except to define how to handle the exception. 19. The complexity of Binary search algorithm is A) O(n). B) O(n2). C) O(log n). D) O(n log n). Show Answer Correct Answer: C) O(log n). 20. Stack is also called as A) First in first out. B) Last in last out. C) Last in first out. D) First in last out. Show Answer Correct Answer: C) Last in first out. 21. A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as ..... A) Tree. B) Stack. C) Linked list. D) Queue. Show Answer Correct Answer: D) Queue. 22. Which of these in NOT a linear data structure? A) Tree. B) Array. C) Queue. D) Stack. Show Answer Correct Answer: A) Tree. 23. What is the method to get all keys from a dictionary? A) Use 'dict.keys()' to get all keys from a dictionary. B) Use 'dict.all keys()' to fetch all keys from a dictionary. C) Call 'list.keys()' to access dictionary keys. D) Use 'dict.get()' to retrieve keys from a dictionary. Show Answer Correct Answer: A) Use 'dict.keys()' to get all keys from a dictionary. 24. What method in Python is used to add an element to a set? A) Modify(). B) Add(). C) Insert(). D) Update(). Show Answer Correct Answer: B) Add(). 25. How do you iterate over the items in a tuple? A) Access items in a tuple using their index only. B) Use a for loop to iterate over the items in a tuple. C) Convert the tuple to a list and then iterate over it. D) Use a while loop to iterate over the items in a tuple. Show Answer Correct Answer: B) Use a for loop to iterate over the items in a tuple. 26. Number of possible ordered trees with 3 nodes A, B, C is A) Op 1:16. B) Op 2:12. C) Op 4:14. D) Op 3:13. Show Answer Correct Answer: B) Op 2:12. 27. ..... technique is used by solving optimization problems A) Divide and conquer. B) Greedy method. C) Dynamic programming. D) Both b and c. Show Answer Correct Answer: D) Both b and c. 28. Which iteration method is commonly used with arrays? A) FOR. B) WHILE. C) ELSE. D) IF. Show Answer Correct Answer: A) FOR. 29. How can you handle multiple exceptions in a single try block? A) Handle exceptions in a separate function. B) Use multiple except clauses or a tuple of exceptions in a single except clause. C) Ignore exceptions entirely. D) Use a single except clause for all exceptions. Show Answer Correct Answer: B) Use multiple except clauses or a tuple of exceptions in a single except clause. 30. ..... data structures are those whose sizes and structures associated memory locations are fixed at compile time. A) Homogeneous. B) Static. C) Linear. D) Dynamic. Show Answer Correct Answer: B) Static. 31. Is the syntax for the following C statement correct?:scanf("%d", input); A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 32. What are the different methods available for adding elements to a list in Python? A) Add(). B) There are several methods available for adding elements to a list in Python, including append(), extend(), insert(), and list concatenation. C) Pop(). D) Remove(). Show Answer Correct Answer: B) There are several methods available for adding elements to a list in Python, including append(), extend(), insert(), and list concatenation. 33. Which syntax correctly creates a list? A) Nums = {1, 2, 3}. B) Nums = 1, 2, 3. C) Nums = [1, 2, 3]. D) Nums = (1, 2, 3). Show Answer Correct Answer: C) Nums = [1, 2, 3]. 34. Consider the following two sequences:The length of longest common subsequence of X and Y is:Consider the following two sequences:X = < B, C, D, C, A, B, C >, and Y = < C, A, D, B, C, B >The length of longest common subsequence of X and Y is: A) 5. B) 2. C) 4. D) 3. Show Answer Correct Answer: C) 4. 35. In linked list each node is divided into ..... parts? A) Three. B) Two. C) One. D) Four. Show Answer Correct Answer: B) Two. 36. What is the purpose of the len() function in Python? A) Adds items to a List or Dictionary. B) Returns the number of items in a List, Tuple, or Dictionary. C) Deletes items from a List or Dictionary. D) Sorts the items in a List or Dictionary. Show Answer Correct Answer: B) Returns the number of items in a List, Tuple, or Dictionary. 37. In single linked list, the pointer of last node contains A) Only address. B) Address of first node. C) Null. D) Only data value. Show Answer Correct Answer: C) Null. 38. When a pop() operation is called on an empty queue, what is the condition called? A) Overflow. B) Garbage value. C) Syntax error. D) Underflow. Show Answer Correct Answer: D) Underflow. 39. In ..... data structures all elements may or may not be of same type. A) Non linear. B) Homogeneous. C) Linear. D) Non-homogeneous. Show Answer Correct Answer: D) Non-homogeneous. 40. What is the primary advantage of using a linked list over an array? A) Faster access to elements by index. B) Dynamic memory allocation allowing efficient insertions and deletions. C) Requires less memory for storage. D) Simplified sorting algorithms. Show Answer Correct Answer: B) Dynamic memory allocation allowing efficient insertions and deletions. 41. How can you use string comprehension in Python? A) You can create strings using the syntax '[]' for item in iterable. B) You can use string comprehension in Python by using the syntax ''.join(expression for item in iterable if condition). C) Use string comprehension by applying 'map()' on the iterable directly. D) String comprehension is done with the format 'str(item) for item in iterable'. Show Answer Correct Answer: B) You can use string comprehension in Python by using the syntax ''.join(expression for item in iterable if condition). 42. Which data structure in Python is best suited for implementing a queue? A) List. B) Set. C) Dictionary. D) Deque. Show Answer Correct Answer: D) Deque. 43. What is a full binary tree? A) A binary tree where each node has exactly two children. B) A binary tree where each node has either 0 or 2 children. C) A binary tree with exactly one node. D) A binary tree where every node has exactly one child. Show Answer Correct Answer: A) A binary tree where each node has exactly two children. 44. Which of the following abstract data types can be used to represent a many to-many relation? A) Op 3:Graph. B) Op 1:Tree. C) Op 2:Stack. D) Op 4:Queue. Show Answer Correct Answer: A) Op 3:Graph. 45. What is the function peak means? A) Showing all elements in a stack. B) Showing the last index value. C) Deleting the last index value. D) Showing zeroth index value. Show Answer Correct Answer: C) Deleting the last index value. 46. In Python, which data structure can be implemented using a list with append and pop operations? A) Stack. B) Set. C) Queue. D) Dictionary. Show Answer Correct Answer: A) Stack. 47. In Python, which data structure is used to store an ordered collection of individual items? A) Dictionary. B) Set. C) List. D) Tuple. Show Answer Correct Answer: C) List. 48. Data structure provide a means to manage huge amount of data ..... A) Efficiently. B) Inefficiently. C) With complexity. D) With problems. Show Answer Correct Answer: A) Efficiently. 49. If I add 2 elements that are the same to a python set what will happen? A) Python sets are all unique, so it will only be put in once. B) There will be 2 of the same elements within the set. C) All the above. D) None of the above. Show Answer Correct Answer: A) Python sets are all unique, so it will only be put in once. 50. In Binary trees nodes with no successor are called ..... A) Final nodes. B) Last nodes. C) Terminal nodes. D) End nodes. Show Answer Correct Answer: C) Terminal nodes. 51. Efficiency of an algorithm is measured by A) Time and Capacity complexity. B) Time and Space complexity. C) Speed and Space complexity. D) Speed and Capacity complexity. Show Answer Correct Answer: B) Time and Space complexity. 52. Which of the following is non-liner data structure? A) Array. B) Stack. C) Graph. D) List. Show Answer Correct Answer: C) Graph. 53. A field or collection of fields in a record which identifies a record uniquely is called a ..... A) Primary Key. B) Secondary Key. C) None of the above. D) None of the above. Show Answer Correct Answer: A) Primary Key. 54. In one dimensional array if LB = 0 and UB = 10 then the array size is ..... A) 11. B) 9. C) 12. D) -1. Show Answer Correct Answer: A) 11. 55. In a stack, if a user tries to remove an element from empty stack it is called ..... A) Empty collection. B) Overflow. C) Garbage Collection. D) Underflow. Show Answer Correct Answer: D) Underflow. 56. 4 trees are B-trees of order 4. They are an isometric of ..... trees. A) AVL. B) AA. C) 2-3. D) Red-Black. Show Answer Correct Answer: D) Red-Black. 57. What is the purpose of keys in a dictionary? A) To store data in a linear format. B) The purpose of keys in a dictionary is to uniquely identify and access values. C) To sort values alphabetically. D) To create a list of values. Show Answer Correct Answer: B) The purpose of keys in a dictionary is to uniquely identify and access values. 58. Types of data structures are ..... A) Primitive and non-primitive. B) Linear and non-linear. C) Static and dynamic. D) All above. Show Answer Correct Answer: D) All above. 59. Which one of the following is an application of Stack Data Structure? A) Managing function calls. B) The stock span problem. C) Arithmetic expression evaluation. D) All the above. Show Answer Correct Answer: D) All the above. 60. Explain the use of the 'finally' block in exception handling. A) The 'finally' block is only executed if an exception occurs. B) The 'finally' block guarantees execution of code after try and except blocks, regardless of exceptions. C) The 'finally' block can be skipped if the code is running in a loop. D) The 'finally' block is used to define a new exception type. Show Answer Correct Answer: B) The 'finally' block guarantees execution of code after try and except blocks, regardless of exceptions. ← PreviousNext →Related QuizzesScience QuizzesClass 12 QuizzesClass 12 Computer Science Chapter 1 Data Structures Using Python Quiz 1Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 3Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 4Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 5Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 6Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 7Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 8Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 9 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books