I've found how to do. Here's the code:
import numpy as np
print (" Résolution de systèmes de n équations à n inconnues :")
# Saisie du nombre d’inconnues
print ("\n")
m = int(input(" Nombre d’inconnues ? "))
n = m
mat_a = []
mat_b = []
# Saisie des coefficients - matrice A
print ("\n")
print (" Saisie des coefficients – Matrice [A] :")
for i in range (0,n):
mat_a.append([])
for i in range (0,m):
for j in range (0,n):
mat_a[i].append(j)
mat_a[i][j]=0
for i in range (0,m):
for j in range (0,n):
print (" Coefficient [", i+1,", ",j+1, "] ?", end = " ")
mat_a[i][j] = eval(input())
# Saisie des coefficients - matrice B
m = 1
print ("\n")
print (" Saisie des coefficients – Matrice [B] :")
for i in range (0,n):
mat_b.append([])
for i in range (0,n):
for j in range (0,m):
mat_b[i].append(j)
mat_b[i][j]=0
for i in range (0,n):
for j in range (0,m):
print (" Coefficient [", i+1,", ",j+1, "] ?", end = " ")
mat_b[i][j] = eval(input())
# Création des matrices
a = np.array ([mat_a])
b = np.array ([mat_b])
# Résolution du système d’équations
x = np.linalg.solve(a, b)
# Affichage des solutions
print ("\n")
print (" L’équation admet", n, "solutions. S = {", x, "}.")
# Sortie du programme
print ("\n")
input (" Appuyer sur <Entrée> pour quitter…")
I was helped by a video on youtube: How to make a 2D list or matrix in Python and take a input from user
After a few changes, I managed to write the good code for my little program.
If you want to give it a try, with the following system, for example:
4x + 2y = -1
3x - y = 2
The two solutions are S = {0,3 ; -1,1}.
:)
W.