To define a generator, you use the ____ keyword in the function definition.

  • break
  • continue
  • return
  • yield
In Python, to define a generator, you use the yield keyword within a function. A generator function produces an iterator, which can be used to generate a sequence of values lazily, conserving memory and improving performance.

To define a metaclass, you generally override the _____ method to customize class creation.

  • class
  • init
  • metaclass
  • new
To define a metaclass, you generally override the __new__ method. This method is responsible for creating the class itself and can be customized to modify class attributes and behavior during creation.

To enable database migrations in Flask, the ____ extension can be used.

  • Flask-Database
  • Flask-Migrate
  • Flask-ORM
  • Flask-SQLAlchemy
To enable database migrations in Flask, the Flask-Migrate extension is used. Flask-Migrate is an extension that integrates the Alembic database migration framework with Flask applications, allowing you to manage database schema changes easily.

To find the shortest path in a graph with non-negative edge weights, the ____ algorithm can be used.

  • Binary
  • Bubble
  • Dijkstra's
  • Quick
To find the shortest path in a graph with non-negative edge weights, you can use Dijkstra's algorithm. This algorithm efficiently calculates the shortest path from a source vertex to all other vertices in a weighted graph.

To get all the keys from a Python dictionary, you can use the ____ method.

  • get()
  • items()
  • keys()
  • values()
To obtain all the keys from a Python dictionary, you should use the keys() method. This method returns a view object that displays a list of all the keys in the dictionary.

In which data structure are elements connected using pointers to form a sequence?

  • Array
  • Linked List
  • Queue
  • Stack
A linked list is a data structure where elements are connected using pointers to form a sequence. Each element (node) contains data and a reference (pointer) to the next element in the sequence. Linked lists are dynamic and allow efficient insertions and deletions in the middle of the sequence.

In which library would you find the DataFrame data structure, commonly used in conjunction with Scikit-learn for data manipulation and analysis?

  • Matplotlib
  • NumPy
  • Pandas
  • Scikit-learn
The Pandas library is where you would find the DataFrame data structure, which is extensively used for data manipulation and analysis. While NumPy and Matplotlib serve other purposes, Pandas is the go-to library for structured data handling.

In which scenarios is it most appropriate to use a metaclass instead of a class?

  • When you need to customize the behavior of a specific instance.
  • When you want to create a simple object.
  • When you want to customize the behavior of a group of classes.
  • When you want to define a new data type.
Metaclasses are most appropriate when you need to customize the behavior of a group of classes, such as enforcing coding standards, implementing singletons, or automating repetitive tasks for classes. They are not typically used for customizing individual instance behavior.

Python's ____ allows classes to be created dynamically, at runtime.

  • decorators
  • inheritance
  • metaclasses
  • polymorphism
Python's "metaclasses" allow classes to be created dynamically, at runtime. Metaclasses are responsible for creating and configuring classes.

The ____ algorithm is commonly used to dynamically optimize and solve overlapping subproblems.

  • Backtracking
  • Divide and Conquer
  • Dynamic Programming
  • Greedy
The Dynamic Programming algorithm is commonly used to dynamically optimize and solve overlapping subproblems. It stores the results of subproblems to avoid redundant computation.