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 5 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 5 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which of the following best describes the purpose of a try-except block in Python?Criterion 2:Apply reasoning to solve real-world problems in various contexts A) It makes code more readable. B) It ensures the program runs faster. C) It helps to store large amounts of data. D) It prevents a program from crashing due to errors. Show Answer Correct Answer: D) It prevents a program from crashing due to errors. 2. In Stack Insertion and deletion of an element is done at single end called ..... A) Top. B) Start. C) Last. D) Bottom. Show Answer Correct Answer: A) Top. 3. How can you create a dictionary from two lists? A) Use dict(list1, list2). B) Use dict(zip(list1, list2)). C) Use zip(list1, list2). D) Use list(zip(list1, list2)). Show Answer Correct Answer: B) Use dict(zip(list1, list2)). 4. How do you modify an element at a specific index in a list? A) By removing the element at the specific index and adding a new element with the desired value. B) By using the 'replace' function to replace the element at the specific index with a new value. C) By accessing the element using its index and assigning a new value to it. D) By using the 'update' function to update the element at the specific index with a new value. Show Answer Correct Answer: C) By accessing the element using its index and assigning a new value to it. 5. Which data structure follows FIFO System? A) Stack. B) Queue. C) Array. D) All of these. Show Answer Correct Answer: B) Queue. 6. Which of the following operations is performed more efficiently by doubly linked list than by linear linked list? (ISRO CS 2001) A) Searching an unsorted list for a given item. B) Inserting a node after the node with a given location. C) Traversing the list to process each node. D) Deleting a node whose location is given. Show Answer Correct Answer: D) Deleting a node whose location is given. 7. Which of the following data structures allow insertion and deletion from both ends? A) Stack. B) Double Ended Queue(Deque). C) Queue. D) Strings. Show Answer Correct Answer: B) Double Ended Queue(Deque). 8. This structure uses a pointer to link nodes. A) Pointer. B) Trees. C) Link List. D) Variable. Show Answer Correct Answer: C) Link List. 9. X = 5 while x > 0:print("Counting down!") A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 10. What is a nested list and how can you access its elements? A) A nested list is a type of dictionary; access elements using keys. B) A nested list is a single list with no sublists; access elements using a single index. C) A nested list is a flat structure; elements can be accessed in any order. D) A nested list is a list containing other lists; access elements using multiple indices. Show Answer Correct Answer: D) A nested list is a list containing other lists; access elements using multiple indices. 11. State true of false.i) A node is a parent if it has successor nodes.ii) A node is child node if out degree is one. A) False, True. B) True, False. C) True, True. D) False, False. Show Answer Correct Answer: B) True, False. 12. Array or linear list comes under the category of ..... A) Compound Data Structure. B) Simple Data Structure. C) Random Data Structure. D) None of these. Show Answer Correct Answer: B) Simple Data Structure. 13. What will be the output of the following code snippet for 1$\rightarrow$2$\rightarrow$3$\rightarrow$4$\rightarrow$5? void solve (ListNode* head) \{ while(head != NULL) \{ cout << head $\rightarrow$ data << '' "; head = head $\rightarrow$ next; \}\} A) 1 2 3 4 5. B) 2 4 1 3 5. C) 5 4 3 2 1. D) 1 3 5 2 4. Show Answer Correct Answer: A) 1 2 3 4 5. 14. Quick sort follows which type of algorithm A) Greed. B) Top down. C) Divide and Conquer. D) Branch and bound. Show Answer Correct Answer: C) Divide and Conquer. 15. Circular Queue is also known as ..... A) Ring Buffer. B) Curve Buffer. C) Rectangle Buffer. D) Square Buffer. Show Answer Correct Answer: A) Ring Buffer. 16. This stores its elements in a special type of tree where elements are sorted either natural or custom during iteration. A) LinkedHashSet. B) Set. C) TreeSet. D) HashSet. Show Answer Correct Answer: C) TreeSet. 17. It is a linear data structure that stores a collection of elements. Operates on first in first out (FIFO) algorithm. A) Queue. B) Data structure. C) Stack. D) Array. Show Answer Correct Answer: A) Queue. 18. In ..... type of linked lists we can traverse in both the directions. A) Doubly linked list. B) Singly linked list. C) Circular linked list. D) One dimensional linked list. Show Answer Correct Answer: A) Doubly linked list. 19. An exam was attended by 80 students. Min marks-0, Max Mark-50. I need to store the frequency of marks >30. What will be the size of the array needed for it? A) 50. B) 80. C) 30. D) 20. Show Answer Correct Answer: D) 20. 20. How do you initialize an array in C? A) Int arr[3] = {1, 2, 3};. B) Int arr[3] = (1, 2, 3);. C) Int arr(3) = (1, 2, 3);. D) Int arr(3) = {1, 2, 3};. Show Answer Correct Answer: A) Int arr[3] = {1, 2, 3};. 21. Consider the following operation performed on a stack of size 5.Push(1);Pop();Push(2);Push(3);Pop();Push(4);Pop();Pop();Push(5);After the completion of all operation, the number of elements present in stack are A) 3. B) 2. C) 1. D) 4. Show Answer Correct Answer: C) 1. 22. Suppose each set is represented as a linked list with elements in arbitrary order. Which of the operations among union, intersection, membership, cardinality will be the slowest? (GATE CS 2004) A) Union. B) Union, intersection. C) Cardinality. D) Membership. Show Answer Correct Answer: B) Union, intersection. 23. Explain the difference between a list and a tuple in Python. A) A list is immutable and defined with [], while a tuple is mutable and defined with (). B) Both lists and tuples are mutable and defined with []. C) A list can contain only integers, while a tuple can contain any data type. D) A list is mutable and defined with [], while a tuple is immutable and defined with (). Show Answer Correct Answer: D) A list is mutable and defined with [], while a tuple is immutable and defined with (). 24. A linked list have A) Address. B) Value. C) Both Address and value. D) None. Show Answer Correct Answer: C) Both Address and value. 25. Match the following.a) Completeness i) How long does it take to find a solutionb) Time Complexity ii) How much memory need to perform the search.c) Space Complexity iii) Is the strategy guaranteed to find the solution when there in one. A) A-i, b-iii, c-ii. B) A-i, b-ii, c-iii. C) A-iii, b-i, c-ii. D) A-iii, b-ii, c-i. Show Answer Correct Answer: C) A-iii, b-i, c-ii. 26. Compound Data structure can be ..... & ..... A) Simple and Nested. B) Linear and Non Linear. C) Sequential and random. D) None of the above. Show Answer Correct Answer: B) Linear and Non Linear. 27. The elements of static list are stored in A) Successive memory locations. B) Random memory locations. C) Alternate memory locations. D) None of the above. Show Answer Correct Answer: A) Successive memory locations. 28. A terminal node in a binary tree is called ..... A) Child. B) Leaf. C) Branch. D) Root. Show Answer Correct Answer: B) Leaf. 29. Which data structure is needed to convert infix notation to postfix notation? A) List. B) Tree. C) Queue. D) Stack. Show Answer Correct Answer: D) Stack. 30. Which sorting algorithm is known for its average time complexity of O(n log n)? A) Merge sort. B) Selection sort. C) Bubble sort. D) Insertion sort. Show Answer Correct Answer: A) Merge sort. 31. How can you merge two dictionaries in Python? A) By using the 'merge' method available on dictionaries. B) By using the 'update' method or the '|' operator in Python 3.9 and later. C) By using a for loop to iterate through the keys of both dictionaries. D) By converting them to lists and concatenating. Show Answer Correct Answer: B) By using the 'update' method or the '|' operator in Python 3.9 and later. 32. How do you raise an exception in Python? A) Raise 'Error message'. B) Raise Exception(). C) Throw Exception('Error message'). D) Raise Exception('Error message'). Show Answer Correct Answer: D) Raise Exception('Error message'). 33. Can I put different data types into a set? A) Idk. B) I should know but I forgot:(. C) No. D) Yes. Show Answer Correct Answer: D) Yes. 34. What will be the output of the program?class Main{public static void main(String args[]) {int arr[] = {10, 20, 30, 40, 50};for(int i=0; i < arr.length; i++){System.out.print(" '' + arr[i]);}}} A) 10 20 30 40 50. B) Compiler Error. C) 10 20 30 40. D) None of the above. Show Answer Correct Answer: A) 10 20 30 40 50. 35. What is the syntax for creating a tuple in Python? A) A tuple is created using parentheses, e.g., (1, 2, 3). B) A tuple is created using angle brackets, e.g., <1, 2, 3>. C) A tuple is created using curly braces, e.g., {1, 2, 3}. D) A tuple is created using square brackets, e.g., [1, 2, 3]. Show Answer Correct Answer: A) A tuple is created using parentheses, e.g., (1, 2, 3). 36. Assertion (A):A queue is a FIFO data structure.Reason (R):Addition and deletion of items takes place at same end. A) A is true and R is correct explanation. B) A is true and R is incorrect explanation. C) A is true and R is true. D) A is false and R is false. Show Answer Correct Answer: B) A is true and R is incorrect explanation. 37. How can you use comprehension with tuples? A) You can convert a set to a tuple using set(x for x in iterable). B) You can use a generator expression to create a tuple, e.g., tuple(x for x in iterable). C) You can use a list comprehension to create a tuple, e.g., [x for x in iterable]. D) You can use a dictionary comprehension to create a tuple, e.g., {x:x for x in iterable}. Show Answer Correct Answer: B) You can use a generator expression to create a tuple, e.g., tuple(x for x in iterable). 38. How can you remove an item from a list by its value? A) Use list.pop(index) to remove an item by its value. B) Use list.remove(value) to remove an item by its value. C) Use del list[index] to remove an item by its value. D) Use list.clear() to remove all items from the list. Show Answer Correct Answer: B) Use list.remove(value) to remove an item by its value. 39. Which data structure allows deleting data elements from front and inserting from rear? A) Linked List. B) Queue. C) Array. D) Stack. Show Answer Correct Answer: B) Queue. 40. Which of the following is NOT a typical use case for a queue? A) Managing tasks in a print server. B) Handling IO buffers in networking. C) Implementing recursive function calls. D) Implementing breadth-first search in graph traversal. Show Answer Correct Answer: C) Implementing recursive function calls. 41. What methods can be used with dictionaries? A) Add, remove, clear, merge, find, search. B) Append, insert, delete, replace, copy, clone. C) Methods that can be used with dictionaries include get, keys, values, items, update, and pop. D) First, last, next, previous, count, sort. Show Answer Correct Answer: C) Methods that can be used with dictionaries include get, keys, values, items, update, and pop. 42. Arrays can have different data types?True or False? A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 43. Identify the data structure which allows deletions at both ends of the list but insertion at only one end. A) Output restricted dequeue. B) Circular queue. C) Priority queue. D) Input restricted dequeue. Show Answer Correct Answer: D) Input restricted dequeue. 44. What are the key-value pairs in a dictionary? A) Key-value pairs consist of a unique key and its associated value, formatted as 'key:value'. B) Key-value pairs are lists of strings without any structure. C) Key-value pairs are unordered collections of items. D) Key-value pairs are only numeric values without keys. Show Answer Correct Answer: A) Key-value pairs consist of a unique key and its associated value, formatted as 'key:value'. 45. Which syntax correctly creates a set? A) Fruits = ["apple", "banana", "orange"]. B) Fruits = "apple, banana, orange". C) Fruits = {"apple", "banana", "orange"}. D) Fruits = ("apple", "banana", "orange"). Show Answer Correct Answer: C) Fruits = {"apple", "banana", "orange"}. 46. Records would typically be seen in use with which type of software? A) Database. B) Image editor. C) Browser. D) Defragmenter. Show Answer Correct Answer: A) Database. 47. What does the following function do for a given Linked List with first node as head? void fun1(struct node* head)\{ if(head == NULL) return; fun1(head$\rightarrow$next); printf("%d ", head$\rightarrow$data);\} A) Prints all nodes of linked lists. B) Prints all nodes of linked list in reverse order. C) Prints alternate nodes of Linked List. D) Prints alternate nodes in reverse order. Show Answer Correct Answer: B) Prints all nodes of linked list in reverse order. 48. Which of the following principle does queue use? A) FIFO. B) Linear. C) LIFO. D) Ordered. Show Answer Correct Answer: A) FIFO. 49. How do you iterate over a dictionary's keys and values? A) For key, value in my dict.items():. B) For key in my dict.keys():. C) For value in my dict.values():. D) For item in my dict:. Show Answer Correct Answer: A) For key, value in my dict.items():. 50. What are the advantages of using a set over a list? A) Advantages of using a set over a list include uniqueness of elements, faster membership tests, support for mathematical operations, and no order maintenance. B) Sets allow duplicate elements. C) Sets maintain the order of elements. D) Lists provide faster membership tests. Show Answer Correct Answer: A) Advantages of using a set over a list include uniqueness of elements, faster membership tests, support for mathematical operations, and no order maintenance. 51. How many stacks are required for reversing a word algorithm? A) One. B) Two. C) Three. D) Four. Show Answer Correct Answer: A) One. 52. ..... is neither an algorithm nor a program. A) Computing. B) Pseudo code. C) Computer science. D) None of the above. Show Answer Correct Answer: B) Pseudo code. 53. The post fix form of (A + B) *C is A) AB+ C*. B) ABC*+. C) ABC*+. D) ABC*+. Show Answer Correct Answer: A) AB+ C*. 54. Which one of the following is the process of inserting an element in the stack? A) Insert. B) Add. C) Push. D) None of the above. Show Answer Correct Answer: C) Push. 55. What is the purpose of using sets in Python? Provide an example. A) Sets are used to store duplicate elements and perform mathematical operations. B) Sets are used to store elements in a specific order and perform sorting operations. C) Sets are used to store unique elements and perform set operations. D) Sets are used to store elements in a sequential manner and perform string operations. Show Answer Correct Answer: C) Sets are used to store unique elements and perform set operations. 56. How many edges are in a tree? A) N * 1. B) N / 1. C) N + 1. D) N-1. Show Answer Correct Answer: D) N-1. 57. List some common methods available for strings in Python. A) Join(). B) ['upper()', 'lower()', 'strip()', 'split()', 'replace()']. C) Find(). D) Concat(). Show Answer Correct Answer: B) ['upper()', 'lower()', 'strip()', 'split()', 'replace()']. 58. The data type keyword NOT supported in C Language is: A) Union. B) Pointer. C) Double. D) Enum. Show Answer Correct Answer: B) Pointer. 59. Give syntax to create a node for Single linked list? A) Newnode=(struct node *)malloc(sizeof(struct node*));. B) Newnode=(struct node )malloc(sizeof(struct node));. C) Newnode=(struct node *)malloc(sizeof(struct node));. D) Newnode=(struct node )malloc(sizeof(struct node*));. Show Answer Correct Answer: A) Newnode=(struct node *)malloc(sizeof(struct node*));. 60. Can We Implement Stack Using Queue Data structure A) Yes. B) No. C) All the above. D) None of the above. Show Answer Correct Answer: A) Yes. ← 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 2Class 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 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