In [11]:
for num in range(1,101):
a = []
prime = True
for i in range(2,num): # for-loop to check for "primeness" by checking for divisors other than 1
if (num%i==0): # logical test for the number having a divisor other than 1 and itself
prime = False # if there's a divisor, the boolean value gets flipped to False
if prime: # if prime is still True after going through all numbers from 1 - 100, then it gets printed
a.append(num)
b = a[::2]
print(b)
In [6]:
for num in range(1,101):
if all(num%i!=0 for i in range(2,num)):
print(num)
In [ ]: