If d is a dictionary, the method d.______() will return a list of all the values in the dictionary.

  • extract_values
  • get_values
  • list_values
  • values
The values() method in Python returns a view object that displays a list of all the values in the dictionary. You can convert this view to a list if needed.

Which of the following can be used to import only a specific function or class from a module?

  • from module import function
  • import function from module
  • import module
  • import module.function
You can use 'from module import function' to import only a specific function or class from a module in Python.

The true mechanism behind private attributes in Python is a feature called _______.

  • abstraction
  • data hiding
  • encapsulation
  • name mangling
Python uses a technique called "name mangling" to make attributes private by adding a prefix to their names.

In Python, which of the following is an immutable data type?

  • Dictionary
  • List
  • Set
  • Tuple
The correct option is 4. Tuples are immutable in Python, meaning their elements cannot be changed after they are created.

What is the primary difference between the methods append() and extend() when applied to a list?

  • append() adds one item
  • append() extends lists
  • extend() adds elements
  • extend() appends lists
The primary difference between append() and extend() is that append() adds a single item to the end of a list, while extend() adds the elements of an iterable (e.g., another list) to the end of the list. This means extend() is used to combine two lists, while append() adds an element as it is, even if it's a list itself.

One of the potential issues with excessive nested if statements is reduced ______ of code.

  • modularity
  • performance
  • readability
  • verbosity
One of the potential issues with excessive nested 'if' statements is reduced readability of code due to increased verbosity.

If you have import pandas as pd, what does "pd" represent?

  • It is the author's initials.
  • It stands for "Python Data."
  • It's a common convention for aliasing pandas.
  • It's a random abbreviation for the library.
When you use import pandas as pd, you are creating an alias for the pandas library. "pd" is a commonly used abbreviation for pandas in the Python community, making it easier to reference and use pandas functions and classes in your code without typing the full module name each time.

You have two sets, one containing all employees who attended a training session and another with employees who completed an online assessment. You want to find out who attended the training but did not complete the assessment. Which set operation would help?

  • Difference
  • Intersection
  • Symmetric Difference
  • Union
To find employees who attended training but did not complete the assessment, you would use the "Difference" set operation. This will give you the elements that are in the first set but not in the second.

Which keyword is used to define a function in Python?

  • def
  • define
  • func
  • function
In Python, the keyword 'def' is used to define a function. For example, 'def my_function():' defines a function named 'my_function.'

Which logical operator is used in Python to combine conditional statements and returns True only if one of the conditions is True?

  • and
  • not
  • or
  • xor
The 'or' logical operator in Python is used to combine conditional statements. It returns 'True' if at least one of the conditions is 'True.'