Chapter 2: Problem 11
Binomial coefficients The binomial coefficient \(\left(\begin{array}{l}n \\ k\end{array}\right)\) is an integer equal to $$ \left(\begin{array}{l} n \\ k \end{array}\right)=\frac{n !}{k !(n-k) !}=\frac{n \times(n-1) \times(n-2) \times \ldots \times(n-k+1)}{1 \times 2 \times \ldots \times k} $$ when \(k \geq 1\), or \(\left(\begin{array}{l}n \\ 0\end{array}\right)=1\) when \(k=0\). a) Using this form for the binomial coefficient, write a Python user-defined function binomial \((\mathrm{n}, \mathrm{k})\) that calculates the binomial coefficient for given \(n\) and \(k\). Make sure your function returns the answer in the form of an integer (not a float) and gives the correct value of 1 for the case where \(k=0\). b) Using your function write a program to print out the first 20 lines of "Pascal's triangle." The \(n\)th line of Pascal's triangle contains \(n+1\) numbers, which are the coefficients \(\left(\begin{array}{l}n \\\ 0\end{array}\right),\left(\begin{array}{l}n \\ 1\end{array}\right)\), and so on up to \(\left(\begin{array}{l}n \\ n\end{array}\right)\). Thus the first few lines are $$ \begin{aligned} &11 \\ &121 \\ &1331 \\ &14641 \end{aligned} $$ c) The probability that an unbiased coin, tossed \(n\) times, will come up heads \(k\) times is \(\left(\begin{array}{l}n \\ k\end{array}\right) / 2^{n}\). Write a program to calculate (a) the total probability that a coin tossed 100 times comes up heads exactly 60 times, and (b) the probability that it comes up heads 60 or more times.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.