#!/usr/bin/env python3 # Display roots of quadratic equation. # example: qeq.py 1 -4.6 4.08 # Import standard modules. import math import sys # Extract command-line arguments. a = float(sys.argv[1]) b = float(sys.argv[2]) c = float(sys.argv[3]) # Determinant. det = b**2 - 4 * a * c roots = None, None # Store roots as a tuple. if det >= 0: roots = (-b + math.sqrt(det)) / (2 * a), (-b - math.sqrt(det)) / (2 * a) print(roots)