Implement Infinite Fibonacci Generator Using Lazy Evaluation
CitadelData Scientist · Technical ScreenLast 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.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.