Example 6. A fair coin is tossed three times. What is the probability that heads will come up exactly twice?
Solution. Let's introduce the notation: $A_{k}$ - "the appearance of a digit on the $k$-th coin toss $(k=1,2,3)$ ", $A$ - "the appearance of two digits in three tosses", then

$$
A=A_{1} A_{2} \bar{A}_{3}+A_{1} \bar{A}_{2} A_{3}+\bar{A}_{1} A_{2} A_{3}
$$

Since the terms on the right side of this equation are pairwise mutually exclusive, we obtain by formula (1.8.3) for $n=3$

$$
P(A)=P\left(A_{1} A_{2} \bar{A}_{3}\right)+P\left(A_{1} \bar{A}_{2} A_{3}\right)+P\left(\bar{A}_{1} A_{2} A_{3}\right)
$$

Taking into account the independence of events $A_{1}, A_{2}, A_{3}$, we find

$$
\begin{aligned}
& P(A)=P\left(A_{1}\right) P\left(A_{2}\right) P\left(\bar{A}_{3}\right)+P\left(A_{1}\right) P\left(\bar{A}_{2}\right) P\left(A_{3}\right)+P\left(\bar{A}_{1}\right) P\left(A_{2}\right) P\left(A_{3}\right)= \\
& =\frac{1}{2} \cdot \frac{1}{2} \cdot \frac{1}{2}+\frac{1}{2} \cdot \frac{1}{2} \cdot \frac{1}{2}+\frac{1}{2} \cdot \frac{1}{2} \cdot \frac{1}{2}=\frac{3}{8}
\end{aligned}
$$