I was referring to this lecture Markov Chain Monte Carlo. However, I didn't get how the $\pi$ value was calculated. Here is a screenshot

As far as I know the integral gives the area under the curve. So I didn't get how the double integral is giving the value of $\pi$ using $P(x,y)$.
Also how did it convert to mean in Octave. I am just a beginner. So please some guidance is required
Actually you are counting the number of $\color{blue}{\text{dots}}$, that fall into to $\color{red}{\text{quarter circle}}$ divided by the total number of $\color{blue}{\text{dots}}$, which has area $\frac \pi4$.
You can use the "mean", since for a large number of $\color{blue}{\text{dots}}$, it approximates the integral.
EDIT If you would use $\color{blue}{\text{water }}$instead of $\color{blue}{\text{dots}}$, something like this was already written in the bible:
And he made a molten sea, ten cubits from the one brim to the other: it was round all about, and his height was five cubits: and a line of thirty cubits did compass it about. (I Kings 7, 23; II Chronicles 4, 2.)