How To Use Sin(x) And Cos(x) Functions With Eval
I need a program which can make graphs by matplotlib with functions I write in the console. But it doesn't work with trigonometric functions. The code I already wrote is: from num
Solution 1:
I Don't exactly understand what you want to do but that might help:
from numpy import linspace, sin, cos, tan
import matplotlib.pyplot as plt
a = float(input('Enter x0: '))
b = float(input('Enter x1: '))
x = linspace(a, b, 1001)
for trig_func in [sin, cos]:
y = trig_func(x)
plt.title(f'{trig_func.__name__}(x)')
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.show()
Please explain how you try to implement eval function..
Post a Comment for "How To Use Sin(x) And Cos(x) Functions With Eval"