🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: itertools and functools: all 10 questions

Quiz: itertools and functools · Question 10 of 10

What does cmptokey let you do?

What does cmp_to_key let you do?

  1. A.Compare two dictionaries
  2. B.Turn a key function into a comparison
  3. C.Sort with a function that compares two items and returns negative, zero or positive
  4. D.Sort without using any key
Answer & explanation

Correct answer: Sort with a function that compares two items and returns negative, zero or positive

It adapts a two-argument comparison for use as key= in sorted().

Can you get the rest right without peeking?

Take the timed Quiz: itertools and functools quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →