TypeError: range() integer end argument expected, got float. If I use Integer It will not include 3 as Prime Number...I do not want to add 3 same like 1...Code-->import  mathdef is_prime(n):    if n==1:        return False    if n == 2:        return True    if n > 2  and  n%2 == 0:        return  False    max_divisor =math.floor(math.sqrt(n))    for d  in range(3,1 + max_divisor , 2 ) :        if  n  %  d  == 0  :            return False        return  Truefor n in range(1,21):    print (n,is_prime(n))
Python Prime_Numbers Algorihtms TypeError()
python
Instead of using math.floor(), just cast the square root to an int, i.e: max_divisor = int(math.sqrt(n))The return True should be outside of the for loopYou might also want to add something to catch weird input, such as if type(n) is not int or n <= 0 -> return None. If you have this you can also eliminate the first part of if n > 2  and  n%2 == 0:The following should work:import mathdef is_prime(n):    if type(n) is not int or n <= 0:        return None    if n==1:        return False    if n == 2:        return True    if n%2 == 0:        return  False    max_divisor = int(math.sqrt(n))    for d in range(3, 1 + max_divisor, 2):        if n % d == 0  :            return False    return Truefor n in range(1,21):    print (n,is_prime(n))Output:$ python review.py(1, False)(2, True)(3, True)(4, False)(5, True)(6, False)(7, True)(8, False)(9, False)(10, False)(11, True)(12, False)(13, True)(14, False)(15, False)(16, False)(17, True)(18, False)(19, True)(20, False)If the range at the end is just to demonstrate that your function works then that's fine. But if you specifically need the primes over an interval, try implementing a sieve instead.