Skip to content

Instantly share code, notes, and snippets.

@giovannibenussi
Last active April 6, 2017 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giovannibenussi/05fe2b25eb5de2dacef59205db532870 to your computer and use it in GitHub Desktop.
Save giovannibenussi/05fe2b25eb5de2dacef59205db532870 to your computer and use it in GitHub Desktop.
import math
a = float(input("Ingrese el valor de a: "))
b = float(input("Ingrese el valor de b: "))
c = float(input("Ingrese el valor de c: "))
print("Ecuación: " + str(a) + " * x * x + " + str(b) + " * x + " + str(c))
print("a: " + str(a))
print("b: " + str(b))
print("c: " + str(c))
print()
# ========== Concavidad ==========
if a > 0:
print("La parábola es cóncava")
elif a < 0:
print("La parábola es convexa")
else: # a == 0
print("La parábola es ???")
# ========== Discriminante ==========
radicando = b * b - 4 * a * c
if radicando >= 0:
discriminante = math.sqrt(radicando)
print("Discriminante: " + str(discriminante))
else:
print("No se pudo calcular el discriminante porque el radicando es menor a cero")
# ========== Vértice ==========
vertice_x = -b / (2 * a)
vertice_y = a * vertice_x * vertice_x + b * vertice_x + c
print("Vertice: (" + str(vertice_x) + ", " + str(vertice_y) + ")")
# ========== X1 y X2 ==========
if radicando > 0:
discriminante = math.sqrt(radicando)
if radicando > 0:
x_1 = (-b + discriminante) / (2 * a)
x_2 = (-b - discriminante) / (2 * a)
print("X1: " + str(x_1))
print("X2: " + str(x_2))
elif radicando == 0:
x_1 = (-b + discriminante) / (2 * a)
print("X1: " + str(x_1))
else:
print("La parábola no posee punto de corte con el eje de las ordenadas")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment