Programation Deuxieme Annee - Odt

You might also like

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 4

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.

1914 64 bit (AMD64)] on win32


Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> def transvection_ligne(M,i,j,l):
... M[i]=[M[i][k]+l*M[j][k] for k in range (len(M[i]))]
... return M
...
>>> def echange_lignes(M,i,j):
... M[i],M[j]=M[j],M[i]
... return M
...
>>> def recherche_pivot_lignes(M,i):
... m=abs(M[i][j])
... j=i
... for k in range(i+l,len(M)):
... if abs(M[i][j])>m:
... j=k
... return j
...
>>> def pivot_ligne(M):
... for i in range (len(M)):
... j=recherche_pivot_lignes(M,i)
... if j!=i:
... echang_lignes(M,i,j)
... if M[i][i]!=0:
... for j in range(i+1,len(M)):
... transvection_ligne(M,j,i,-M[j][i]/M[i][i])
... return M
...
>>> def determinant(M):
... pivot_lignes(M)
... p=l
... for i in range (len(M)):
... p*=M[i][i]
... return p
...
>>> a=[[1,1],[1,1]]
>>> determinant(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in determinant
NameError: name 'pivot_lignes' is not defined
>>> def determinant(M):
... pivot_lignes(M)
... p=1
... for i in range (len(M)):
... p*=M[i][i]
... return p
...
>>> a=[[1,1],[1,1]]
>>> determinant(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in determinant
NameError: name 'pivot_lignes' is not defined
>>> for j in range(i+1,len(M)):
File "<stdin>", line 1
for j in range(i+1,len(M)):
^
IndentationError: unexpected indent
>>>
>>>
>>> import numpy
>>> def transvection_ligne(M,i,j,l):
... M[i]=[M[i][k]+l*M[j][k] for k in range (len(M[i]))]
... return M
...
>>> def echange_lignes(M,i,j):
... M[i],M[j]=M[j],M[i]
... return M
...
>>> def recherche_pivot_lignes(M,i):
... m=abs(M[i][j])
... j=i
... for k in range(i+l,len(M)):
... if abs(M[i][j])>m:
... j=k
... return j
...
>>> def pivot_lignes(M):
... for i in range (len(M)):
... j=recherche_pivot_lignes(M,i)
... if j!=i:
... echang_lignes(M,i,j)
... if M[i][i]!=0:
... for j in range(i+1,len(M)):
... transvection_ligne(M,j,i,-M[j][i]/M[i][i])
... return M
...
>>> def determinant(M):
... pivot_lignes(M)
... p=l
... for i in range (len(M)):
... p*=M[i][i]
... return p
... a=[[1,1],[1,1]]
File "<stdin>", line 7
a=[[1,1],[1,1]]
^
SyntaxError: invalid syntax
>>> def determinant(M):
... pivot_lignes(M)
... p=l
... for i in range (len(M)):
... p*=M[i][i]
... return p
...
>>> a=[[1,1],[1,1]]
>>> determinant(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in determinant
File "<stdin>", line 3, in pivot_lignes
File "<stdin>", line 2, in recherche_pivot_lignes
UnboundLocalError: local variable 'j' referenced before assignment
>>> def determinant(M):
... pivot_lignes(M)
... p=1
... for i in range (len(M)):
... p*=M[i][i]
... return p
...
>>> a=[[1,1],[1,1]]
>>> determinant(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in determinant
File "<stdin>", line 3, in pivot_lignes
File "<stdin>", line 2, in recherche_pivot_lignes
UnboundLocalError: local variable 'j' referenced before assignment
>>> def determinant(M):
... pivot_lignes(M)
... p=l
... for i in range (len(M)):
... p *=M[i][i]
... return p
...
>>> a=[[1,1],[1,1]]
>>> determinant(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in determinant
File "<stdin>", line 3, in pivot_lignes
File "<stdin>", line 2, in recherche_pivot_lignes
UnboundLocalError: local variable 'j' referenced before assignment
>>>
>>> def determinant(M):
... pivot_lignes(M)
... p=l
... for i in range (len(M)):
... p*=M[i][i]
... return p
...
>>> M=[[1,1,1],[1,1,1]]
>>> determinant(M)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in determinant
File "<stdin>", line 3, in pivot_lignes
File "<stdin>", line 2, in recherche_pivot_lignes
UnboundLocalError: local variable 'j' referenced before assignment
>>> def determinant(M):
... pivot_lignes(M)
... p=l
... for i in range (len(M)):
... p*=M[i][i]
... return p
...
>>> M=[[1,1],[1,1]]
>>> determinant(M)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in determinant
File "<stdin>", line 3, in pivot_lignes
File "<stdin>", line 2, in recherche_pivot_lignes
UnboundLocalError: local variable 'j' referenced before assignment
>>>
>>> def recherche_pivot_lignes(M,i):
... m=abs(M[i][i])
... j=i
... for k in range(i+1,len(M)):
... if abs(M[i][j])>m:
... j=k
... return j
...
>>> M=[[1,1],[1,1]]
>>> determinant(M)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in determinant
NameError: name 'l' is not defined
>>> def determinant(M):
... pivot_lignes(M)
... p=1
... for i in range (len(M)):
... p*=M[i][i]
... return p
...
>>> M=[[1,1],[1,1]]
>>> determinant(M)
0.0

You might also like