As pointed out at Number of tosses to ensure $95\%$ that the coin selected is double-headed, the existing answer to this question is incorrect, as it doesn't take into account the given information on how the coin was chosen.
The existing answer answers the question how many times you'd have to throw heads in a row so that the probability for a fair coin to produce that result would be less than $5\%$. I understand the question to ask instead how many times you'd have to throw heads in a row so that the conditional probability for the coin to be fair, given how it was chosen, would be less than $5\%$.
As calculated by @Idonknow in the question linked to above, the answer is $8$. The conditional probability for the coin to be double-headed after $n$ heads in a row is
\begin{eqnarray*}
P(\text{double}\mid\text{$n$ heads})
&=&
\frac{P(\text{double}\land\text{$n$ heads})}{P(\text{$n$ heads})}
\\
&=&
\frac{P(\text{$n$ heads}\mid\text{double})P(\text{double})}{P(\text{$n$ heads})}\;.
\\
&=&
\frac{1\cdot\frac1{10}}{1\cdot\frac1{10}+\left(\frac12\right)^n\cdot\frac9{10}}
\\
&=&
\frac1{1+9\cdot2^{-n}}\;.
\end{eqnarray*}
For this to be $\ge95\%$, we need $1+9\cdot2^{-n}\le\frac1{0.95}$ and thus
$$
n\ge\log_2\frac9{\frac1{0.95}-1}=\log_2171\approx7.4\;,
$$
so we need $8$ consecutive heads to be $95\%$ sure that the selected coin is the double-headed coin.
Note that the number of fair coins appears in the numerator of the argument of the logarithm. That means that every time we double the number of fair coins, we need one more throw of heads to reach the same level of certainty. For instance, if we had $4\cdot9=36$ fair coins and one double-headed one to choose from, we'd need $10$ consecutive throws of heads to reach $95\%$ certainty that we chose the double-headed one.
Part 1: if the coin is fair, it comes up $H$ with probability $\frac 12$. If it is unfair then it comes up $H$ with probability $$\int_0^1 pdp=\frac 12$$. Thus the two cases are symmetric and the answer is $\boxed {\frac 12}$.
Part II. Now the probability that the unfair coin comes up $HH$ is $$\int_0^1 p^2dp=\frac 13$$ While the fair coin of course comes up $HH$ with probability $\frac 14$. Thus we apply Bayes to get $$\frac {\frac 12 \times \frac 14}{\frac 12 \times \frac 13+\frac 12 \times \frac 14}=\boxed {\frac 37}$$
Best Answer
With a sample as large as $n = 1000$ and $p$ in the vicinity of 1/2, a normal approximation should work well.
To test the null hypothesis $H_0: p = .5$ against the alternative $H_a: p > .5$ you need to compute the test statistic $$Z = \frac{\hat p - p_0}{\sqrt{p_0(1-p_0)/n}}.$$
In your example, you have $\hat p = 0.51,\,p_0 = 0.5,$ and $n = 1000.$ You would reject the null hypothesis $H_0,$ saying that the data from the $n = 1000$ flips of the coin are inconsistent with the behavior of a fair coin, at the 5% level if $Z > 1.645.$ (The 'critical value' cutting 5% of the probability from the upper tail of a standard normal distribution, can be found from printed normal CDF tables or from software.)
I will leave it to you to finish this. Please compare this with what is in your textbook, and leave a Comment if you still need help.
Notes: It would not be unusual to get 510 or more Heads in 1000 tosses of a fair coin. That would happen over 25% of the time. A truly unusual outcome would be to get exactly 500 Heads in 1000 tosses (probability about 0.025). Results from R statistical software: