Skip to content

Instantly share code, notes, and snippets.

@c272
Last active May 8, 2018 08:35
Show Gist options
  • Select an option

  • Save c272/65e7eeeb3e168a3e06a1513960d1d8c8 to your computer and use it in GitHub Desktop.

Select an option

Save c272/65e7eeeb3e168a3e06a1513960d1d8c8 to your computer and use it in GitHub Desktop.
Quadratic Formula in Python 3
#Quadratic formula import, Python 3.6
#C272, 2018
from math import *
def solveQuad(a,b,c):
a = float(a)
b = float(b)
c = float(c)
rootb = sqrt(b)
bsq = b**2
ans = ["",""]
ans[0] = (-b + sqrt(bsq-(4*a*c)))/(2*a)
ans[1] = (-b - sqrt(bsq-(4*a*c)))/(2*a)
return ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment