# Determine the number of roots of a quadratic equation using a function # Determine the number of roots of a quadratic equation # Parameters: # a: The coefficient of x^2 # b: The coefficient of x # c: The constant term # Returns: The number of real roots (0, 1, or 2) def numRoots(a, b, c): # Compute the discriminant of the quadratic equation disc = b ** 2 - 4 * a * c if disc > 0: # 2 real roots return 2 elif disc == 0: # 1 real root return 1 else: # 0 real roots return 0 # Report the number of roots for an equation entered by the user def main(): # Read the coefficients of x^2 and x and the constant term print("Consider an equation of the form a x^2 + b x + c = 0") a = int(input("Enter the value of a: ")) b = int(input("Enter the value of b: ")) c = int(input("Enter the value of c: ")) # Compute the number of roots and display the result n = numRoots(a, b, c) print("The number of roots is:", n) main()