← Quiz: Design Search Autocomplete: all 10 questions
Quiz: Design Search Autocomplete · Question 2 of 10
What does this print? (code)
What does this print?
top = [(700, "java"), (900, "javascript"), (50, "jam"), (400, "java ide")]
top.sort(key=lambda p: (-p[0], p[1]))
print([q for c, q in top[:2]])
- A.['java', 'javascript']
- B.['javascript', 'java']
- C.['jam', 'java']
- D.['javascript', 'java ide']
Answer & explanation
Correct answer: ['javascript', 'java']
Sorting by negative count puts the highest counts first: 900, then 700.
Can you get the rest right without peeking?
Take the timed Quiz: Design Search Autocomplete quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →