Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 29)
29.
How can you implement a generator that produces a sequence of prime numbers?
Using a loop with a yield statement and a prime-checking function
By calling a recursive function with yield
Using a list comprehension with yield
By using the itertools.cycle() function
Answer: Option
Explanation:
A generator for a sequence of prime numbers can be implemented using a loop with a yield statement and a function to check for prime numbers.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.