Skip to content

Instantly share code, notes, and snippets.

@danybeltran
Created September 23, 2023 00:26
Show Gist options
  • Save danybeltran/79e62c5272d2cb65de9b23c563e476e2 to your computer and use it in GitHub Desktop.
Save danybeltran/79e62c5272d2cb65de9b23c563e476e2 to your computer and use it in GitHub Desktop.
formula general
import math
def cuadratica(a, b, c):
parte2 = math.sqrt(b**2 - 4 * a * c)
resultado1 = -b + parte2
resultado2 = -b - parte2
results = dict()
results["x1"] = resultado1 / (2 * a)
results["x2"] = resultado2 / (2 * a)
return results
results = cuadratica(1, -5, 6)
print("x1: {}, x2: {}".format(results.get("x1"), results.get("x2")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment