Assessment: Creating functions

Oct 1, 2014 • Olivier Lafleur
  1. Please tell which of these function definitions will compile without error in Python 2.7 :
    a)
def discriminant(a, b, c):
return pow(b, 2) - 4*a*c

b)

def discriminant(a, b, c):
    return pow(b, 2) - 4*a*c

c)

discriminant(a, b, c):
    return pow(b, 2) - 4*a*c

d)

def discriminant(a, b, c)
    return pow(b, 2) - 4*a*c
  1. By using the discriminant function (the correct one!), write a function that calculate and print the roots of a quadratic equation (if you need a little refresh : http://en.wikipedia.org/wiki/Discriminant#Quadratic_formula).