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

Quiz: RAG · Question 6 of 10

What does this print? (code)

What does this print?

def chunk_text(text, size, overlap):
    words = text.split()
    chunks, start = [], 0
    while start < len(words):
        chunks.append(words[start:start + size])
        if start + size >= len(words):
            break
        start += size - overlap
    return chunks

print(len(chunk_text(" ".join(str(i) for i in range(50)), size=20, overlap=5)))
  1. A.2
  2. B.3
  3. C.4
  4. D.5
Answer & explanation

Correct answer: 3

Chunks start at words 0, 15 and 30; the last one reaches the end.

Can you get the rest right without peeking?

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

Start the quiz →