Question #6481   Proposée par Answiki le 25/08/2022 à 7:01:27 UTC

Comment soustraire deux tableaux en Python ?

Answer   Submitted by Answiki on 08/25/2022 at 07:23:34 PM UTC

Le moyen le plus simple de soustraire deux tableaux (np.array) en Python est d'utiliser la méthode np.subtract(). Voici un exemple :

import numpy as np
 
A = np.array([1, 2, 3, 4])
B = np.array([1, 4, 2, 8])

# Subtraction : R = A - B
R = np.subtract(A, B)

# R = [0 -2 1 -4]
print(R)




2 events in history
Answer by Answiki on 08/25/2022 at 07:23:34 PM

Le moyen le plus simple de soustraire deux tableaux (np.array) en Python est d'utiliser la méthode np.subtract(). Voici un exemple :

import numpy as np
 
A = np.array([1, 2, 3, 4])
B = np.array([1, 4, 2, 8])

# Subtraction : R = A - B
R = np.subtract(A, B)

# R = [0 -2 1 -4]
print(R)




Question by Answiki 08/25/2022 at 07:01:27 AM
Comment soustraire deux tableaux en Python ?
# ID Query URL Count

Icons proudly provided by Friconix.