ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
import itertools
it = itertools.count(10, 5)
print(list(itertools.islice(it, 3)), next(it))
  1. A. [10, 15, 20] 25
  2. B. [10, 15, 20] 20
  3. C. [10, 15, 20] 30
  4. D. [10, 15] 20

Correct answer: A. [10, 15, 20] 25

count(10, 5) yields 10, 15, 20, 25, and so on. islice takes the first three values, and the next value from the same iterator is the fourth one, 25.

More Python Programming questions

Exams that ask this topic