A ____ in Python is a collection of key-value pairs, where the keys must be immutable.
- Dictionary
- List
- Set
- Tuple
A ____ is a data structure that stores elements in a linear sequence but allows additions and removals only at the start.
- Array
- Linked List
- Queue
- Stack
A ____ is a linear data structure where the elements are arranged in a circular fashion.
- Linked List
- Queue
- Ring Buffer
- Stack
A ____ is a special type of binary tree where each node has a higher (or equal) value than its children.
- AVL Tree
- Binary Search Tree (BST)
- B-Tree
- Red-Black Tree
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
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
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.