<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def shannon_entropy(p):
 """Calculates shannon entropy in bits. Parameters p : np.array array of probabilities Returns ------- shannon entropy in bits """

    return -np.sum(np.where(p!=0, p * np.log2(p), 0))