Trace une courbe du second degré, à partir de coefficients a,b, et c que vous donnez.
from math import sqrt from matplotlib import pyplot as plt from mathsup import disc a = float(input("a = ")) b = float(input("b = ")) c = float(input("c = ")) x = -10, 10, 0.1 def f(x,a,b,c): return a*x**2+b*x+c y = f(x,a,b,c) plt.plot(x,y,"red") plt.grid(True) if a != 0 and disc(a,b,c) >= 0: delta = disc(a,b,c) if delta == 0: x0 = -b/2*a plt.text(x0, f(x0,a,b,c), "x0") else: x1 = (-b+sqrt(delta))/(2*a) x2 = (-b-sqrt(delta))/(2*a) plt.text(x1, f(x1,a,b,c), "x1 = " + str(x1)) plt.text(x2, f(x2,a,b,c), "x2 = " + str(x2)) plt.title("Courbe Cf (en rouge) de la fonction f = " + str(a) + "x2+" + str(b) + "x+" + str(c)) plt.ylabel("f(x)") plt.xlabel("x") plt.show()