**Python Puzzles**

Simulate a multiple-choice exam where you divide the questions into three probabilities of attaining a correct answer.

- Questions that have a 100% confidence of being correct
- Questions that have a 1/3 confidence of being correct
- Questions that have a 1/4 confidence of being correct

After running 10,000 simulations of the exam, determine the following:

- Average number of correct answers
- Minimum and maximum number of correct answers
- Percentage of the exams where the number of correct answers is over some desired value
- Standard Deviation

Here is the code I developed in Python. In my simulation I choose a 50 question exam where my desired score of 35 was attained 74% of the time.

```
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
desired_score = 35
known_guess = 1
educated_guess = 1/3
random_guess = 1/4
simulations = 1_000_000
np_result = np.random.binomial(30,known_guess,simulations)
np_result = np.add(np_result,np.random.binomial(10,educated_guess,simulations))
np_result = np.add(np_result,np.random.binomial(10,random_guess,simulations))
filter_arr = np_result >= 35
newarr = np_result[filter_arr]
probability_desired_score = len(newarr)/len(np_result)
print('Probability of obtaining a score of ' + str(desired_score) + ' or greater is ' + '{0:.2%}'.format(probability_desired_score))
print('The average score is' + '{0:.2%}'.format(np.average(np_result)))
print('The minimum score is' + '{0:.2%}'.format(np.min(np_result)))
print('The maximum score is' + '{0:.2%}'.format(np.max(np_result)))
print('The standard deviation is' + '{0:.2%}'.format(np.std(np_result)))
df = pd.Series(np_result)
df = df.value_counts()
print(df.sort_index())
plt.bar(df.index, df.values)
plt.title('Distribution of Correct Answers')
plt.xlabel('Correct Answers')
plt.ylabel('Frequency')
plt.xticks(np.arange(min(df.index), 51, 2))
plt.show()
```

**Here are the results of the print statements.**

Probability of obtaining a score of 35 or greater is 74%

The average score is 36

The minimum score is 30

The maximum score is 46

The standard deviation is 2

**This Pandas Series shows the number of questions correct on the left and the occurrences on the right. **

1,917 exam simulations had 36 correct answers.

Reviewing the bar chart we can see the data fits a normal distribution.