Académique Documents
Professionnel Documents
Culture Documents
TP2
Listes
Monsieur :
Hamida soufiane
Présenter par :
EL FAKIHI YASSIR
EX 1 :
EX 2 :
def function(z):
n = len(z)
l_even = []
l_odd = []
résultat : 7
EX 4 :
t = int(input('num :'))
a = []
for s in range(1, t+1):
if t % s == 0:
x = t/s
a.append(x)
print(a)
EX 5:
L1 = [11 , 3 , 22 , 7 , 13 , 23 , 9]
L2 = [5 , 9 , 19 , 23 , 10 , 23 , 13]
L = []
for x in L1:
if x not in L2:
L.append(x)
print(L)
EX 6 :
L1 = [7 , 23 , 5 , 12 , 7 , 19 , 23 , 12 , 29]
def function(L):
duplicate = []
for x in L:
if L.count(x) > 1 and x not in duplicate:
duplicate.append(x)
return duplicate
print(function(L))