1
I made a code that calculates Bhaskara for me and I was thinking of making this program show the graph of the equation as well, but I don’t know how to do that. if anyone knows how to do this, please give a help to me. follow the code.
Note: the graph is a parable.
print("="*20)
valor_a = float(input("Digite o valor de A: "))
print("="*20)
valor_b = float(input("Digite o valor de B: "))
print("="*20)
valor_c = float(input("Digite o valor de C: "))
print("="*20)
delta = ((valor_b)**2)-(4*valor_a*valor_c)
valor_x1 = (-(valor_b)+((delta)**(1/2)))/(2*valor_a)
valor_x2 = (-(valor_b)-((delta)**(1/2)))/(2*valor_a)
valor_xV = -(valor_b)/(2*valor_a)
valor_yV = -(delta)/(4*valor_a)
print("Delta=", delta)
print("="*20)
print("X1=", valor_x1)
print("="*20)
print("X2=", valor_x2)
print("="*20)
print("Xv=", valor_xV)
print("="*20)
print("Yv=", valor_yV)
print("="*20)
if you want to highlight the X1 and x2 values on the chart... Swap the last three lines with: fig = plt.figure() Ax = fig.add_subplot(111) plt.Plot(eixo_x,eixo_y,color="blue") plt.Plot(eixo_x,zero,color="black") Ax.annotate(str(value_x1),xy=(value_x1,0.0)) Ax.annotate(str(value_x2),xy=(valor_x2,0.0)) plt.show()
– Shoo Limberger