n = int(input())
xs, fs = [], []
for _ in range(n):
    x, f = map(float, input().split(' '))
    xs.append(x)
    fs.append(f)
print(xs, fs)
mean = lambda xs, fs: sum(x * f for x, f in zip(xs, fs))
variance = lambda xs, fs: sum(x**2 * f for x, f in zip(xs, fs)) - mean(xs, fs)**2

mu, V = mean(xs, fs), variance(xs, fs)
sigma = V**0.5
print(f"Espérance : {mu}")
print(f"Variance : {V}")
print(f"Ecart-type : {sigma}")

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: