It's an exercise from Bayes Rules! An Introduction to Bayesian Modeling with R.
Lactose intolerance is an inability to digest milk, often resulting in an upset stomach. Fatima wants to learn more about the proportion of adults who are lactose intolerant, $\pi$. Her prior model for $\pi$ is:
| $\pi$ | 0.4 | 0.5 | 0.6 | 0.7 | Total |
|---|---|---|---|---|---|
| $f(\pi)$ | 0.1 | 0.2 | 0.44 | 0.26 | 1 |
Fatima surveys a random sample of 80 adults and 47 are lactose intolerant.
How to calculate the likelihood in order to figure out the posterior model?

Put $A = \{ $ 47 are intolerant and 33 are not $\}$.
$$P( A| \pi = p) = \binom{80}{33}p^{47}(1-p)^{33} $$ Hence we know $P( A| \pi = p)$ for all four values of $p$.
By Bayes' theorem, $$P(\pi= p | A) = \frac{ P( A| \pi = p) f(p) }{ \sum_j P( A| \pi = p_j) f(p_j) }$$