Recall the has_roots function that we wrote.

In [2]:
def has_roots(a, b, c):
    '''Return True iff ax^2+bx+c=0 has real roots
    
    [Note: Return True iff ... means, in Python (but not in math!) Return 
    True if ax^2+bx+c=0 has real roots and False otherwise]
    
    Arguments:
    a, b, c -- floats
    '''
    
    disc = b**2-4*a*c
    
    This is not the nicest way to write this -- we'll rewrite this function later
    if disc >= 0:
        return True
    else:
       return False
  File "<ipython-input-2-554e0617b195>", line 13
    This is not the nicest way to write this -- we'll rewrite this function later
                         ^
SyntaxError: invalid syntax

Let's rewrite it a bit:

In [3]:
def has_roots(a, b, c):    
    disc = b**2-4*a*c
    return disc >= 0

This does exactly the same thing: since the value of disc >= 0 is True exactly when $disc\geq 0$, we return True when $disc\geq 0$, and False when $disc < 0$.

Let's not write a similar function, has_no_roots. Here's is one option:

In [4]:
def has_no_roots(a, b, c):
    disc = b**2-4*a*c
    return disc < 0

Here's another:

In [5]:
def has_no_roots(a, b, c):
    disc = b**2-4*a*c
    return not (disc >= 0)

Finally, here's the laziest option:

In [6]:
def has_no_roots(a, b, c):
    return not has_roots(a, b, c)

All these functions compute the same thing.