Skip to content

Commit c58bbfe

Browse files
authored
Corriger les exercice de TD 2 et TP 2
1 parent 58e3542 commit c58bbfe

File tree

14 files changed

+158
-1
lines changed

14 files changed

+158
-1
lines changed

TD/TD2/EX3-Q3.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#L'aire A d'un trapèze dont les bases sont B1 et B2 et dont la hauteur est H est : A=((B1+B2)×H) / 2
2+
3+
def surface():
4+
return ((B1+B2)*H)/2
5+
6+
7+
B1 = float(input("Entrer la Base 1 : "))
8+
B2 = float(input("Entrer la Base 2 : "))
9+
H = float(input("Entrer l'Hauteur : "))
10+
11+
print("La Surface de trapèze est : ", surface())

TD/TD2/EX3-Q4.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
def absolue(N):
3+
if N < 0:
4+
return -N
5+
else:
6+
return N
7+
8+
N = float(input("Entrer un nombre : "))
9+
print("|",N,"| = ", absolue(N))

TD/TD2/EX3-Q5.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
def somme(N):
3+
S = 0
4+
for i in range(N+1):
5+
S = S + i
6+
return S
7+
8+
9+
N = int(input("Entrer un nombre : "))
10+
print("La Somme des nombres jusqu'a ", N ,"est : ", somme(N))

TD/TD2/EX3-Q6.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
def SommePremiers(N):
3+
S = 0
4+
if N > 0:
5+
for i in range(N+1):
6+
if (i % 3 != 0 and i % 2 == 0):
7+
S = S + i
8+
return S
9+
10+
N = int(input("Entrer un Nombre Positive : "))
11+
print("La Somme des Nombres est : ", SommePremiers(N))

TP/TP2/EX1-Q1.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from math import sqrt
2+
3+
def fonction(x : float): # car (x ∈ ℝ)
4+
return (x**5) - abs(1 - sqrt(x**2)) + 1 / (1 + x**2)
5+

TP/TP2/EX1-Q2.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from math import sqrt
2+
3+
def fonction(x : float): # car (x ∈ ℝ)
4+
if x >= 0:
5+
return sqrt(x) + 2
6+
elif x < 0:
7+
return (-x)**5

TP/TP2/EX1.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

TP/TP2/EX2-Q1.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#L'aire A d'un trapèze dont les bases sont B1 et B2 et dont la hauteur est H est : A=((B1+B2)×H) / 2
2+
3+
def surface():
4+
return ((B1+B2)*H)/2
5+
6+
7+
B1 = float(input("Entrer la Base 1 : "))
8+
B2 = float(input("Entrer la Base 2 : "))
9+
H = float(input("Entrer l'Hauteur : "))
10+
11+
print("La Surface de trapèze est : ", surface())

TP/TP2/EX2-Q2.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
def absolue(N):
3+
if N < 0:
4+
return -N
5+
else:
6+
return N
7+
8+
N = float(input("Entrer un nombre : "))
9+
print("|",N,"| = ", absolue(N))

TP/TP2/EX2-Q3.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#Demand:
2+
N = []
3+
for i in range(3):
4+
N.append(int(input("Entrer un entier : ")))
5+
6+
#trouver le max:
7+
def max():
8+
Max = N[0]
9+
for i in range(3):
10+
if Max < N[i]:
11+
Max = N[i]
12+
return Max
13+
14+
#Afficher le max:
15+
print("Le Max est : ", max())

0 commit comments

Comments
 (0)