During data analysis, you are given a set of IDs from two different sources. You need to find IDs that are either in the first set or the second set but not in both. Which set operation will you apply?

  • Difference
  • Intersection
  • Symmetric Difference
  • Union
To find IDs that are in either the first set or the second set but not in both, you would apply the "Symmetric Difference" set operation. This will give you elements that are exclusive to each set.

The _______ attribute of an exception object returns a tuple containing an exception type, a value, and a traceback object.

  • args
  • error_details
  • exception_info
  • traceback_info
The 'args' attribute of an exception object returns a tuple containing information about the exception, including the exception type, a value (exception message), and additional details if any. This information is useful for debugging and error handling.

Which version of Python introduced the print() function as needing parentheses?

  • Python 2.5
  • Python 2.6
  • Python 2.7
  • Python 3.0
In Python 3.0, the print statement was replaced with the print() function, requiring the use of parentheses.

The time complexity of checking the existence of an element in a list is _______.

  • O(1)
  • O(log n)
  • O(n)
  • O(n^2)
The time complexity of checking if an element exists in an unsorted list is O(n), where 'n' is the number of elements in the list. It requires searching through the list linearly to find the element.

The method _______ returns the index of the specified value in the tuple.

  • find()
  • index()
  • locate()
  • search()
The index() method is used to find the index of a specified value within a tuple. It returns the first occurrence of the value's index. If the value is not found, it raises a ValueError.

If a module is imported multiple times in a program, Python by default _______ the module.

  • ignores
  • reimports
  • reloads
  • renames
If a module is imported multiple times in a program, Python by default ignores the module. Once a module is imported, Python keeps track of it and doesn't reload or re-import it again, to avoid duplicate code and potential issues.

The _______ block is executed no matter if the try block raises an error or not.

  • else
  • except
  • finally
  • raise
The finally block is executed regardless of whether an exception is raised in the try block or not. It is often used for cleanup operations.

What is Python's primary scripting paradigm?

  • Functional
  • Imperative
  • Object-oriented
  • Procedural
Python's primary scripting paradigm is object-oriented. However, it supports multiple paradigms like procedural and functional too.

Which statement is used in a loop to terminate it and transfer the execution to the next statement following the loop?

  • break
  • continue
  • exit
  • return
The 'break' statement is used in a loop to terminate it prematurely and transfer the execution to the next statement following the loop. It is often used to exit a loop based on a certain condition.

After installing a package using pip, a colleague isn't able to import it in their script. What could be a probable reason?

  • They are using a different Python interpreter
  • The package is not properly installed
  • The package is not in their system PATH
  • There's a compatibility issue with the package
If a colleague is using a different Python interpreter than the one where the package was installed, they won't be able to import it. This often happens when multiple Python installations exist on the system. It's important to ensure that everyone is using the same Python interpreter or virtual environment. The other options could be potential issues but are not directly related to the colleague's problem.