C3 - W2- Exercise 9

why I didn’t get score for this code: I assumed n= 6
it just gave me 3/10

import numpy as np

Define the number of sides on the dice

num_sides = 6 # Change this value to experiment with different dice

Define the possible outcomes of the dice

outcomes = list(range(1, num_sides + 1))

Calculate the mean and variance of a single throw

mean_single_throw = np.mean(outcomes)
variance_single_throw = np.var(outcomes)

Calculate the mean and variance of the sum of two throws

mean_sum_two_throws = 2 * mean_single_throw
variance_sum_two_throws = 2 * variance_single_throw

Calculate the covariance between the two throws (which will always be 0)

covariance_first_second_throw = 0

Print the results with three digits after the decimal point

print(f"Mean of sum of two throws: {mean_sum_two_throws:.3f}“)
print(f"Variance of sum of two throws: {variance_sum_two_throws:.3f}”)
print(f"Covariance between the first and second throw: {covariance_first_second_throw:.3f}")

Exercise 9 asks you to consider what is the effect of increasing the number of sides ‘n’.

Just computing some values for a six-sided die does not answer the question.