#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Purpose: To compute the roots of a quadratic equation Author: Mary Poppins Date: 3/2/18 Program description: This Python program solves the quadratic equation a x**2 + b * x + c where a, b and c are the coefficients and x is the variable The script computes the two roots and displays them Limitations: Cannot deal with complex roots. Cannot deal with a zero 'a' coefficient. Data dictionary: a, b, c: coefficients of the quadratic equation root_discriminant: square root of the discriminant root1, root2: roots """ # Import the math module - Need that for square root import math # Specify the coefficients of the quadratic equation print("Please input three numbers separated by commas") a, b, c = eval(input("Numbers please: ")) # Compute the square root of the discriminant root_discriminant = math.sqrt(b**2-4*a*c) # Compute the root root1 = (-b + root_discriminant)/(2*a) root2 = (-b - root_discriminant)/(2*a) # Display the answers print('The roots are ',root1,' and ', root2)