I tried to implement Numerical integration/Gauss-Legendre Quadrature using by Python.
And follwing this example

I could get the correct answer but anyway if the function changes to exp(-x^2)
How should i do?
Should i put ^2 over x or over f() or ...? from this formula. and how about the minus?

The following are true for both problems.
The points (nodes) are:
The weights are:
My program calculates the above, but they have a nice closed-form table of the points /nodes for $n=1 ~\ldots~ 5$ on the Wiki.
We want to use Gauss-Legendre Quadrature to find $\int_a^b f(x)~dx$, where:
$$\int_a^b ~f(x)~dx = \int_{-3}^3 ~e^{-x^2}~dx \approx \dfrac{b-a}{2} \sum_{n=1}^5 f\left(\dfrac{b-a}{2}x_i + \dfrac{a+b}{2}\right) = 3 \sum_{i=1}^5 f\left(3x_i\right)$$
This gives us:
$$3 \sum_{i=1}^5 e^{-(3x_i)^2} = 3 (0.000146211 + 0.0352118 + 0.568889 + 0.0352118 + 0.000146211) = 1.91881$$
We can compare this to the exact results of:
$$\int_{-3}^3 ~e^{-x^2}~dx = \sqrt{\pi } \text{erf}(3) \approx 1.77241$$
If we would have taken $10$ nodes, we would have gotten:
$$\int_{-3}^3 ~e^{-x^2}~dx = 1.77224$$
Update
Recall, that when we change the limits of integration, we must rescale the problem to $[-1,1]$ (that is what those $a,b$ terms do in the function definition), so we have:
$$\int_a^b ~f(x)~dx = \int_{0}^1 ~e^{-x^2}~dx \approx \dfrac{b-a}{2} \sum_{n=1}^5 f\left(\dfrac{b-a}{2}x_i + \dfrac{a+b}{2}\right) = \dfrac{1}{2} \sum_{i=1}^5 f\left(\dfrac{1}{2}x_i + \dfrac{1}{2}\right)$$
This gives us:
$$\int_{0}^1 ~e^{-x^2}~dx \approx = \dfrac{1}{2} \sum_{i=1}^5 f\left(\dfrac{1}{2}x_i + \dfrac{1}{2}\right) = \dfrac{1}{2} \sum_{i=1}^5 e^{-\left(\dfrac{1}{2}x_i + \dfrac{1}{2}\right)^2} = 0.746824$$
The exact result is:
$$\frac{1}{2} \sqrt{\pi } \text{erf}(1) \approx 0.746824$$