0
Good evening, good afternoon and good morning. I am 15 years old and am studying about second degree equations, Cartesian plan and functions. Because of this, I made a code to calculate the roots, vertex coordinates, graph and image. The only parts that I’m not able to do is the graph and the image that I have no idea how to do, if anyone can help me, I’m very grateful. Thank you very much in advance.
follows the code below:
import math
print('-' * 30, ' Coeficientes ', '-' * 30)
valorA = int(input('Insira o coeficiente de A: '))
valorB = int(input('Insira o coeficiente de B: '))
valorC = int(input('Insira o coeficiente de C: '))
print('-' * 30, ' Raízes ', '-' * 30)
delta = math.pow(valorB, 2) - (4 * valorA * valorC)
x1 = (-valorB + math.sqrt(delta)) / 2 * valorA
x2 = (-valorB - math.sqrt(delta)) / 2 * valorA
print('Raízes: {:.0f} e {:.0f}'.format(x1, x2))
print('-' * 30, ' Coordenada das vértices ', '-' * 30)
Xv = -valorB / (2 * valorA)
Yv = valorA * math.pow(Xv, 2) + valorB * Xv + valorC
print('V({:.0f}; {:.0f})'.format(Xv, Yv))
First check equation no Wolframalpha and then use the matplotlib to plot the graph. By comparing with the result of Wolfram, if it is correct it means that you have programmed correctly... Otherwise, review your code.
– danieltakeshi