I believe your problem is that the return is in the wrong place. Your code currently only loops through the 2, and any odd number is obviously not divisible by 2. So, it goes into the if n%j==0, returns True, and since a return breaks out of the loop, stops going. So, any odd number will return True.
Instead, try:
def isprime(n):
if n % 1 != 0:
return True
else:
for j in range(2, math.ceil(math.sqrt(n))):
if n % j != 0:
return False
return True
I think that works. EDIT: No, it actually doesn't. Here, I'll post a different prime checker:
def isprime(n):
'''check if integer n is a prime'''
n = abs(int(n))
if n < 2:
return False
if n == 2:
return True
if not n & 1:
return False
for x in range(3, int(n**0.5)+1, 2):
if n % x == 0:
return False
return True