Apart from the problem of the random function I wrote above, the logical problem here is that the result from every run of the code is supposed to be independent. And so, if $w$ is fixed and the code is run for $u$ times, the number of wins follows binomial distribution: $$W\sim B\left(u,\frac pu\right)$$
And while the **expected** number of wins is $p$, there is quite some chance that the resultant number of wins is different from $p$. Actually, $$P[W\
eq p] = 1 - \binom{u}{p}\left(\frac pu\right)^p\left(1-\frac pu\right)^{u-p}$$
If $p$ is fixed and $u$ approaches infinity, the distribution converges to Poisson distribution with expected number of wins $p$. The probability
$$P[W\
eq p]\approx 1-\frac{p^p}{p!}e^{-p}$$
For $p=1$ and $u=10000$, there is over $63\%$ chance that the number of wins is not equal to your $p$.