# Practical Exercises for Chapter 11

Ah, the moment you've all been waiting for—the practical exercises! We promise, the hands-on work is not just immensely educational but also lots of fun. These exercises will help you grasp the concept of probability and the Bayesian Theory more deeply. Let's jump in!

## Exercise 1: Roll the Die

Simulate the roll of a fair six-sided die 1,000 times. Plot a histogram to show the distribution of the results.

import matplotlib.pyplot as plt

import random

results = [random.randint(1, 6) for _ in range(1000)]

plt.hist(results, bins=6, edgecolor='black')

plt.xlabel('Die Face')

plt.ylabel('Frequency')

plt.title('Frequency Distribution of 1,000 Die Rolls')

plt.show()

## Exercise 2: Bayesian Inference for a Coin Toss

You have a biased coin that lands heads 60% of the time. If the coin is tossed 10 times, what is the probability that it lands heads exactly 7 times?

You can use the binomial probability...