Académique Documents
Professionnel Documents
Culture Documents
Correction de TD1:
EX1:
print(x)
x+=1
EXECICE_1(1, 10)
EX2:
if x % 5 == 0 and x % 7 == 0:
x += 1
EX3:
if "e" in x :
print(x)
else:
EX4:
somme = 0
somme = somme + x
x+=1
print(somme)
S(N_1, N_2)
EX5:
def P_D(x):
print(l)
P_D(l)
print(l)
EX6:
MyList = [452, -452, -45, -454, 5, -77, -3, -8, 7, -95, -1, 5]
def positive(x):
if NUM >= 0:
print(NUM)
positive(MyList)
EX7:
MyList = [452, -452, -45, -454, 5, -77, -3, -8, 7, -95, -1, 5]
def sing(x):
pos = 0
neg = 0
for i in x:
if i > 0:
pos += 1
elif i < 0:
neg += 1
sing(MyList)
Correction de TD2:
EX1:
if x % 7 == 0:
elif x % 5== 0:
EX2:
ajoute(5)
EX3:
mult = lambda x, y : x * y
print(mult(5, 7))
EX4:
def PRD(lst):
produit = 1
print(produit)
PRD(L1)
EX5:
vide = []
def carre(x):
nmb = ele**2
vide.append(nmb)
print(x)
carre(vide)
EX6:
y = int(input("entre a nombre : "))
def premier(x):
vide = []
VER = x%i
vide.append(VER)
if 0 in vide:
else:
premier(y)
EX7:
def paire(x):
vide = []
for i in x:
y=i%2
if y == 0:
vide.append(i)
print(vide)
paire(nmbs)
EX8:
list_1 = [1, 55, 45, 45, 45, 45, 63, 12, 411, 411, 411, 75, 75, 75, 75]
def EL(x):
vide = []
for i in x:
if i not in vide:
vide.append(i)
print(vide)
EL(list_1)
EX9:
for i in x:
if i in y:
print(True)
Au_moins(list_1, list_2)
EX10:
def hypot():
somme = 0
z = ((x*10**-2)**2 + (y*10**-2)**2)**0.5
somme = somme + z
print(somme)
hypot()
EX11:
vide = []
if vide == []:
else:
EX12:
EX13:
condition_1 = an % 4
condition_2 = an % 100
condition_3 = an % 400
if condition_3 == 0:
print("Bissextile")
elif condition_2 == 0:
elif condition_1 == 0:
print("Bissextile")
else: