<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def weighted_mean(data):
 """ calculates weighted mean of data """

    W, N, mean, d = 0, len(data), 0, 0
    if N < 1:
        return "", ""
    if N == 1:
        return data[0][0], 0
    for x in data:
        W += x[1]  # sum of the weights
    for x in data:
        mean += old_div((float(x[1]) * float(x[0])), float(W))
    for x in data:
        d += (old_div(float(x[1]), float(W))) * (float(x[0]) - mean)**2
    stdev = np.sqrt(d * (old_div(1., (float(N - 1)))))
    return mean, stdev