12. In 2019, the Mathematics Olympiad underwent a trial reform: A city held 5 joint competitions in the second year of high school. A student who ranks in the top 20 of the city in 2 out of these 5 competitions can enter the provincial team training and does not need to participate in the remaining competitions. Each student can participate in a maximum of 5 competitions. It is stipulated that if the student does not rank in the top 20 of the city in the first 4 competitions, they cannot participate in the 5th competition. Assume that the probability of a student ranking in the top 20 of the city in each competition is $\frac{1}{4}$, and the results of each competition are independent.
(1) Find the probability that the student will enter the provincial team;
(2) If the student enters the provincial team or completes 5 competitions, let the number of competitions the student participates in be $\xi$. Find the distribution of $\xi$ and the expected value of $\xi$.
(1) Let $A=$ “the student makes it to the provincial team”, then $P(\bar{A})=\left(\frac{3}{4}\right)^{4}+C_{4}^{1} \cdot \frac{1}{4} \cdot\left(\frac{3}{4}\right)^{4}=\frac{81}{128}$, so $P(A)=1-P(\bar{A})=\frac{47}{128}$.
(2) $\xi=2,3,4,5$. And $P(\xi=2)=\left(\frac{1}{4}\right)^{2}=\frac{1}{16}, P(\xi=3)=C_{2}^{1} \cdot \frac{3}{4} \cdot\left(\frac{1}{4}\right)^{2}=\frac{3}{32}$, $P(\xi=4)=\left(\frac{3}{4}\right)^{4}+C_{3}^{1} \cdot\left(\frac{3}{4}\right)^{2} \cdot\left(\frac{1}{4}\right)^{2}=\frac{27}{64}, P(\xi=5)=C_{4}^{1} \cdot \frac{1}{4} \cdot\left(\frac{3}{4}\right)^{3}=\frac{27}{64}$. The distribution of $\xi$ is as follows:
\begin{tabular}{|c|c|c|c|c|}
\hline$\xi$ & 2 & 3 & 4 & 5 \\
\hline$P$ & $\frac{1}{16}$ & $\frac{3}{32}$ & $\frac{27}{64}$ & $\frac{27}{64}$ \\
\hline
\end{tabular}

Therefore, $E \xi=2 \cdot \frac{1}{16}+3 \cdot \frac{3}{32}+4 \cdot \frac{27}{64}+5 \cdot \frac{27}{64}=\frac{269}{64}$.