If you have a break in the inner nested loop, will it terminate only the inner loop or both inner and outer loops?

  • Both the inner and outer loops
  • It depends on specific cases
  • Only the inner loop
  • Only the outer loop
A break statement in the inner nested loop will terminate only the inner loop. To break out of both inner and outer loops, you can use labels or flags.

The ______ statement in Python is used to resume the loop from the top.

  • break
  • continue
  • goto
  • return
The continue statement in Python is used to skip the rest of the current iteration of a loop and resume the loop from the top with the next iteration. It allows you to bypass certain iterations based on a condition.

To write a list of dictionaries to a CSV file, one can use the DictWriter class from the _______ module.

  • csv
  • data
  • excel
  • pandas
To write a list of dictionaries to a CSV file in Python, you can use the csv module. Specifically, the DictWriter class from the csv module allows you to write dictionaries as rows in a CSV file, where the keys of the dictionaries are used as column headers. This is a common technique when working with tabular data in Python.

For method overriding to occur, the method in the derived class must have the same _______ and return type as the method in the base class.

  • Method name and arguments
  • Method name and parameters
  • Method signature and name
  • Method signature and parameters
Method overriding in Python requires that the method in the derived class has the same method name and arguments (parameters) as the method in the base class.

In type hinting, if a function is expected not to return any value, the return type should be hinted as _______.

  • Empty
  • None
  • Void
  • nan
In type hinting, if a function is expected not to return any value, the return type should be hinted as 'None'. 'None' signifies the absence of a return value.

For loops in Python utilize the ______ method internally to iterate over items.

  • enumerate
  • iterate
  • loop
  • range
For loops in Python utilize the enumerate method internally to iterate over items. enumerate returns both the index and the value of each item in the sequence, making it useful for tracking positions in the loop.

How does Python internally represent a float value?

  • ASCII Encoding
  • IEEE 754
  • Two's Complement
  • Unicode Encoding
Python internally represents a float value using the IEEE 754 standard for floating-point arithmetic.

The lifetime of a variable is determined by its _______ in the code.

  • assignment
  • data type
  • declaration
  • scope
The lifetime of a variable in Python is determined by its scope in the code. Variables can have different scopes, such as local, enclosing, global, or built-in, which affect their lifespan.

The method _______ is used to remove the first occurrence of a specified value from a list.

  • delete() Method
  • discard() Method
  • pop() Method
  • remove() Method
The 'remove()' method is used to remove the first occurrence of a specified value from a list in Python. It raises an error if the value is not found in the list.

How do you create an empty set in Python?

  • empty_set = []
  • empty_set = set()
  • empty_set = {None}
  • empty_set = {}
To create an empty set in Python, you should use the set() constructor, like this: empty_set = set(). Using {} creates an empty dictionary, not a set.