import numpy as np

np.set_printoptions(precision=3, suppress=True)

state = np.array([0.5, 0.5, 0.7, 0.1])
table = state.reshape(2, 2)
for j in (0, 1):
    column = table[:, j]                       # colonne j : les composantes où le qubit 1 vaut j
    p = float(np.sum(np.abs(column) ** 2))
    print(f"qubit 1 lu {j} : probabilité {round(p, 3)}, puis qubit 0 = {column / np.sqrt(p)}")
