Quiz Home
Python_i_ds_quiz1 Quiz
1: In Python, which data structure is used to implement a stack and queue respectively?
  List and Tuple
  List and List
  Tuple and Dictionary
  Dictionary and List



2: How does a 'set' differ from a 'list' in Python?
  A set is ordered, a list is not
  A set cannot contain duplicate elements, a list can
  A list is faster for iteration
  A set can store complex data types, a list cannot



3: What is the time complexity of accessing an element in a Python list?
  O(1)
  O(n)
  O(log n)
  O(n^2)



4: In Python, what is a 'deque' and which module provides this data structure?
  It's a double-ended queue provided by the 'collections' module
  It's a data type for decimal arithmetic provided by the 'decimal' module
  A debugging tool provided by the 'pdb' module
  A distributed task queue provided by the 'celery' module



5: What is the main characteristic that differentiates a 'frozenset' from a 'set' in Python?
  A frozenset is faster
  A frozenset is ordered
  A frozenset is immutable
  A frozenset can store only numeric values



6: Which Python data structure is commonly used for implementing a graph?
  List
  Set
  Dictionary
  Tuple



7: What is the main advantage of using a 'namedtuple' over a regular tuple in Python?
  It consumes less memory
  It allows for faster access to its elements
  Elements can be accessed by name as well as by index
  It can store more data types



8: How is a 'heap' different from a regular binary tree in Python?
  A heap allows for faster search operations
  A heap is always a complete binary tree, whereas a binary tree need not be
  A heap does not allow duplicate values, but a binary tree does
  A heap is implemented using arrays, while a binary tree uses linked nodes



9: In Python, what does the 'zip' function return when applied to two lists of unequal length?
  A list of tuples with length equal to the shorter list
  A list of tuples with length equal to the longer list
  An error
  A list of tuples filled with None for missing elements



10: When would you use a 'bisect' module in Python?
  For binary tree operations
  For binary search in a sorted list
  For binary encoding and decoding
  For bitwise operations on data