Practice the Python library Matplotlib. It's so common that you don't know what the number is, but please forgive me.
Install with pip.
pip install matplotlib
import matplotlib.pyplot as plt
import numpy as np
# -10 < x < 10
x = np.arange(-10, 10, 0.1)
# a, b,Substitute each value for c
a = int(input("a : "))
b = int(input("b : "))
c = int(input("c : "))
# y = ax^2 + bx + c
y = a*x**2 + b*x + c
#Plot execution to graph
plt.plot(x, y)
plt.show()
a=1, b=2, c=2 | y=x^2+2x+2
a=4, b=5, c=2 | y=4x^2+5x+2
I was able to describe it firmly.
I want to improve it already.
Set title
plt.title("y =" + str(a) + "x²+" + str(b) + "x+" + str(c))
x-axis and y-axis labels
plt.xlabel("x")
plt.ylabel("y", rotation = 0)
Set the display range of y to -5 <y <10
plt.ylim(-5, 10)
Show grid lines
plt.grid()
import matplotlib.pyplot as plt
import numpy as np
# -10 < x < 10
x = np.arange(-10, 10, 0.1)
# a, b,Substitute each value for c
a = int(input("a : "))
b = int(input("b : "))
c = int(input("c : "))
# y = ax^2 + bx + c
y = a*x**2 + b*x + c
#Set title
plt.title("y =" + str(a) + "x²+" + str(b) + "x+" + str(c))
#Other adjustments
plt.xlabel("x") #x-axis label display
plt.ylabel("y", rotation = 0) #Y-axis label display"
plt.ylim(-5, 10) #Display range of y-5 < y <Set to 10
plt.grid() #Show grid lines
#Plot execution to graph
plt.plot(x, y)
a=3, b=2, c=4 | y=3x^2+2x+4
a=2, b=6, c=1 | y=2x^2+6x+1
I think it has become more accurate.
Recommended Posts