Company: Agoda_30july

Difficulty: easy

Problem Statement

Problem Description Create a context manager class called sequence_generator that generates an infinite sequence of numbers. The sequence starts from a given value and increases by a specified step with each iteration. The context manager should expose a generate method that yields numbers in the sequence. Example with sequence_generator(3, 5) as gen: for _ in range(3): print(next(gen), end=" ") Output: 3 8 13 In this example, we create a sequence starting at 3 with a step of 5 . We then retrieve the first three values from the sequence ( 3 , 8 and 13 ). Function Description Complete the class sequence_generator . It should be a context manager class and should expose generate . sequence_generator 's __init__() method has the following parameter(s): int start : the start value. int step : the increment at each call. Entering the with block must hand back an iterator over the sequence, so that next() can be called on it; leaving the block must not raise. Input Format There are 3 lin

More Agoda_30july OA questionsInterview experiences