🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: API Design: all 15 questions

Quiz: API Design · Question 13 of 15

What does this print? (code)

What does this print?

posts = [9, 8, 7, 6, 5, 4]
after = 7
page = [p for p in posts if p < after][:2]
print(page, page[-1])
  1. A.[7, 6] 6
  2. B.[8, 9] 9
  3. C.[6, 5] 6
  4. D.[6, 5] 5
Answer & explanation

Correct answer: [6, 5] 5

The cursor asks for items older than 7; the last item, 5, becomes the next cursor.

Can you get the rest right without peeking?

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

Start the quiz →