import numpy as np import pylab as pl def f(x): return x**2 - (3 * x) - 50 # Improve this function by adding parameters. # For example, pass in the range limit as well as the first # two parameters into linspace. def points(): i = 0 a = np.linspace(-10., 10., 10) # b = np.arange(10) b = np.zeros(10) while i < 10: b[i] = f(a[i]) i = i + 1 return a, b x, y = points() pl.plot(x, y) # I showed how to create a function (points) and use it in this context. # However, we could have easily accomplished the same by simply doing # # pl.plot(x, f(x)) # # without creating the function. pl.show()