How many students had all right answers when $20$ had right first task, $16$ had right second task, $15$ had right third task, $10$ students had right both first and second task, $8$ had right first and third task, and $9$ had right second and third task? Every student had at least one task right. I don't know if I have to apply inclusion-exclusion principle or if it's possible to calculate it without it. I forgot to mention that there are $31$ students.
I tried to apply inclusion-exclusion principle and I ended up with result $7$. Please correct me if I am wrong. I wrote out equation for union of $3$ sets, then I calculated what I could and ended up with $|A \cap B \cap C|+24 = 31$, so $|A \cap B \cap C| = 7$.
Your answer is correct. The Inclusion-Exclusion Principle for three sets states that $$|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|$$ If we define $A$ as the set of students who correctly answered the first task, $B$ as the set of students who correctly answered the second task, and $C$ as the set of students who correctly answered the third task, then we were given \begin{align*} |A \cup B \cup C| & = 31\\ |A| & = 20\\ |B| & = 16\\ |C| & = 15\\ |A \cap B| & = 10\\ |A \cap C| & = 8\\ |B \cap C| & = 9 \end{align*} Hence, \begin{align*} |A \cap B \cap C| & = |A \cup B \cup C| - |A| - |B| - |C| + |A \cap B| + |A \cap C| + |B \cap C|\\ & = 31 - 20 - 16 - 15 + 10 + 8 + 9\\ & = 7 \end{align*} as you found.