Katkat

Implement Infinite Fibonacci Generator Using Lazy Evaluation

CitadelData Scientist · Technical Screen

Last updated

This question evaluates understanding of lazy evaluation and Python generator semantics, testing a candidate's ability to work with iterative sequence production and manage state across iterations.

Scenario

Testing understanding of Python lazy evaluation and generators.

Question

Explain what lazy evaluation means in Python and implement a generator using "yield" that produces an infinite Fibonacci sequence.

Hints

Show how state is preserved between yields and why values are computed only when requested.