Computing Covariance from Joint Probability Distributions - Coding problem | OneNoughtOne