[Solved] Find the max and min values of a function using python


The code you posted will give you a NameError: global name 'numpy' is not defined because of the way you are importing stuff. Instead of doing

from numpy import *

just do

import numpy

Also, the function in numpy is called linspace, not linespace. If you change those two things it will work, but there are still other problems.

You seem not to understand how Python’s imports work. That’s the root of the problem here. Whenever you type from numpy import *, Python finds numpy and puts all the stuff defined in numpy into your current file. So you can’t refer to stuff in numpy as numpy.linspace, numpy.sin, or whatever. You just refer to them as linspace and sin.

7

solved Find the max and min values of a function using python