Trying to understand this simple python code
Question: I was reading Jeff Knupp's blog and I came across this easy little script:

    
    
    
    import math
    
    def is_prime(n):
        if n > 1:
            if n == 2:
                return True
            if n % 2 == 0:
                return False
            for current in range(3, int(math.sqrt(n) + 1), 2):
                if n % current == 0:
                    return False
            return True
        return False
    
    print(is_prime(17))
    
    
    

(note: I added the import math at the beginning. You can see the original
here: <http://www.jeffknupp.com/blog/2013/04/07/improve-your-python-yield-and-
generators-explained/>)

This is all pretty straightforward and I get the majority of it, but I'm not
sure what's going on with his use of the range function. I haven't ever used
it this way or seen anyone else use it this way, but then I'm a beginner. What
does it mean for the range function to have three parameters, and how does
this accomplish testing for primeness?

Also (and apologies if this is a stupid question), but the very last 'return
False' statement. That is there so that if a number is passed to the function
that is less than one (and thus not able to be prime), the function won't even
waste its time evaluating that number, right?


Answer: [The third is the step.](http://docs.python.org/3/library/functions.html#func-
range) It iterates through every odd number less than or equal to the square
root of the input (3, 5, 7, etc.).

