• + 0 comments

    from scipy.stats import pearsonr

    Given data

    physics_scores = [15, 12, 8, 8, 7, 7, 7, 6, 5, 3] history_scores = [10, 25, 17, 11, 13, 17, 20, 13, 9, 15]

    Calculate Pearson's correlation coefficient

    r, _ = pearsonr(physics_scores, history_scores)

    Print the result formatted to three decimal places

    print(f"{r:.3f}")