A ____ is a type of binary tree where the tree automatically balances itself as items are inserted or removed.

  • AVL Tree
  • B-Tree
  • Heap
  • Red-Black Tree
A Red-Black Tree is a type of binary search tree that automatically balances itself during insertions and deletions to ensure the tree remains approximately balanced. This property ensures efficient search and insertion operations.

A ____ loop is used to iterate a block of code a specified number of times.

  • do-while
  • for
  • repeat
  • while
In Python, a for loop is commonly used to iterate over a sequence (such as a list) a specified number of times. The for loop iterates over the elements of the sequence, executing the block of code for each element.

A ____ sort is a highly efficient sorting algorithm based on partitioning of an array of data into smaller arrays.

  • Bubble
  • Merge
  • Quick
  • Selection
A Merge sort is a highly efficient sorting algorithm that uses a divide-and-conquer approach to sort an array. It repeatedly divides the array into smaller sub-arrays until each sub-array is sorted, then merges them back together to achieve the final sorted order.

A ____ tree is a tree in which each node has at most two children, which are referred to as the left child and the right child.

  • Binary
  • Octal
  • Quad
  • Ternary
A Binary Tree is a tree data structure where each node has at most two children, a left child and a right child. This data structure is commonly used in computer science and is fundamental to many algorithms and data structures.

A decorator in Python is a design pattern used to add new functionality to an object without altering its ____.

  • attributes
  • class
  • methods
  • structure
In Python, decorators are typically used to add new functionality to methods of a class without changing the method's name or signature. This is commonly used for tasks like logging, authorization, and caching.

How can you secure sensitive information, like API keys, in a Flask or Django application?

  • Embed them directly in the code
  • Encrypt them using a reversible algorithm
  • Publish them in the application's source code
  • Store them in environment variables
Sensitive information, like API keys, should be stored in environment variables for security. Embedding them directly in the code or publishing them in the source code can expose them, and reversible encryption is not recommended.

To iterate over a list and its indices simultaneously, you can use the ____ function.

  • enumerate
  • for
  • index
  • range

The enumerate function is used in Python to iterate over a list and its corresponding indices. It returns pairs of index-value tuples, making it convenient for tasks that require both the index and the value during iteration.

The ____ keyword is used to create a block of code that can handle exceptions in Python.

  • catch
  • finally
  • throw
  • try

The try keyword is used in Python to create a block of code that might raise exceptions. It is followed by an associated except block that catches and handles those exceptions. This combination allows for controlled error handling in Python.

How can you create an else block that executes after a for loop, but only if the loop completed normally (i.e., did not encounter a break statement)?

  • Place the code after the "for" loop without any specific block.
  • Use the "except" block
  • Use the "finally" block
  • You cannot create an "else" block for this purpose in Python.

In Python, you can create an "else" block that executes after a for loop but only if the loop completed normally (without encountering a "break" statement). To do this, you can use the "else" block immediately following the "for" loop. If the loop completes normally, the "else" block will execute.

What is the output of the following Python code snippet: print(all([True, False, True]))?

  • Error
  • FALSE
  • SyntaxError
  • TRUE

The all() function in Python returns True if all elements in the iterable are True. In this case, it returns False because one of the elements (False) is not True.