🐍 Moyen 5 questions

QCM - Subsection 104.1: Using pandas (Partie 8)

Quiz interactif avec 5 questions. Testez vos connaissances!

#python

Comment jouer ?

  • 1. Lisez chaque question attentivement
  • 2. Choisissez votre réponse parmi les options
  • 3. Cliquez sur "Voir la réponse" pour vérifier
  • 4. Comptez vos bonnes réponses à la fin !

Quiz: QCM - Subsection 104.1: Using pandas (Partie 8)

5 questions | Difficulté: moyen


Question 1

What is the purpose of the ’..’ in the given import statements?

  • A. It refers to a specific function or module
  • B. It is used for parent-level relative imports
  • C. It denotes a global variable
  • D. None of the above
Voir la réponse

Réponse correcte: B

The ’..’ is used for parent-level relative imports. Add more ’.’ with number of levels between the parent and child.


Question 2

What does the builtin function ‘map()’ return in Python 2?

  • A. A list
  • B. A generator
  • C. None
  • D. A tuple
Voir la réponse

Réponse correcte: A

In Python 2, map returns a list.


Question 3

What is the tie-breaking behavior of the ‘round()’ function in Python 3?

  • A. It rounds towards zero
  • B. It rounds to the nearest even number (bankers’ rounding)
  • C. It rounds up if the number is positive and down if it’s negative
  • D. It always returns the same number
Voir la réponse

Réponse correcte: B

In Python 3, round() will return the even integer (aka bankers’ rounding).


Question 4

What should be passed as an identity function in Python 2 when map is used?

  • A. None
  • B. Identity function object
  • C. Function f(x) = x
  • D. Lambda function
Voir la réponse

Réponse correcte: A

In Python 2, None can be passed as an identity function.


Question 5

What is the advantage of using list comprehensions over map in Python?

  • A. List comprehensions are more efficient
  • B. Map is not compatible with Python 3
  • C. List comprehensions are compatible with both Python 2 and 3
  • D. None of the above
Voir la réponse

Réponse correcte: C

Replacing map(str, [1, 2, 3, 4, 5]) with [str(i) for i in [1, 2, 3, 4, 5]] gives the same result and is compatible with both Python 2 and 3.