Simple python generator program for prime numbers


for num in range(2,100):

   for x in range(2, num):

       if num % x == 0:

           #print('{} is not a prime number.'.format(num))

           break

   else:

       print('{} is a prime number.'.format(num))

Output:-

2 is a prime number.

3 is a prime number.

5 is a prime number.

7 is a prime number.

11 is a prime number.

13 is a prime number.

17 is a prime number.

19 is a prime number.

23 is a prime number.

29 is a prime number.

31 is a prime number.

37 is a prime number.

41 is a prime number.

43 is a prime number.

47 is a prime number.

53 is a prime number.

59 is a prime number.

61 is a prime number.

67 is a prime number.

71 is a prime number.

73 is a prime number.

79 is a prime number.

83 is a prime number.

89 is a prime number.

97 is a prime number.