#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ ENGG1811 Lecture Week 4 Solving quadratic equation, use try ... except (Version 1) """ # 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: ")) try: # Compute the square root of the discriminant root_discriminant = math.sqrt(b**2-4*a*c) root1 = (-b + root_discriminant)/(2*a) root2 = (-b - root_discriminant)/(2*a) # Display the answers print('The roots are ',root1,' and ', root2) except: print('Something wrong!')